From eff839b26df8b10b2334e2fbdaf81fbb3236b873 Mon Sep 17 00:00:00 2001 From: Scott Prager Date: Fri, 5 Sep 2014 04:25:34 -0400 Subject: memory: xstrchrnul and xmemscan. --- src/nvim/ops.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/nvim/ops.c') diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 9b98c84be4..2067d863eb 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4903,10 +4903,9 @@ static void str_to_reg(struct yankreg *y_ptr, * Find the end of each line and save it into the array. */ for (start = 0; start < len + extraline; start += i + 1) { - for (i = start; i < len; ++i) /* find the end of the line */ - if (str[i] == '\n') - break; - i -= start; /* i is now length of line */ + // Let i represent the length of one line. + const char_u *p = str + start; + i = (char_u *)xmemscan(p, '\n', len - start) - p; if (i > maxlen) maxlen = i; if (append) { -- cgit