less: trivial code shrink
authorDenys Vlasenko <vda.linux@googlemail.com>
Mon, 22 Sep 2014 19:17:24 +0000 (21:17 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Mon, 22 Sep 2014 19:17:24 +0000 (21:17 +0200)
function                                             old     new   delta
read_lines                                           715     695     -20

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
miscutils/less.c

index 3016c5b47c69d4817cc30ba3bad81d34c6b7b722..c5820d325506ce0e9f17c01a3aa66800df82ec87 100644 (file)
@@ -428,14 +428,13 @@ static void read_lines(void)
                w -= 8;
 
        p = current_line = ((char*)xmalloc(w + 4)) + 4;
-       max_fline += last_terminated;
        if (!last_terminated) {
                const char *cp = flines[max_fline];
-               strcpy(p, cp);
-               p += strlen(current_line);
-               free(MEMPTR(flines[max_fline]));
+               p = stpcpy(p, cp);
+               free(MEMPTR(cp));
                /* last_line_pos is still valid from previous read_lines() */
        } else {
+               max_fline++;
                last_line_pos = 0;
        }