From bdaef0686fabc1900c4b3686de17a3ffd9f4d847 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 17 Jan 2011 12:36:58 +0100 Subject: [PATCH] uniq: replace a wasteful loop with simple calculation * src/uniq.c (find_field): Remove the byte-skipping loop altogether. Instead, perform the simple calculation. This results in a 10% performance improvement for large byte offsets. --- src/uniq.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/uniq.c b/src/uniq.c index 9c7e37c7b9..b35938a19c 100644 --- a/src/uniq.c +++ b/src/uniq.c @@ -222,8 +222,7 @@ find_field (struct linebuffer const *line) i++; } - for (count = 0; count < skip_chars && i < size; count++) - i++; + i += MIN (skip_chars, size - i); return line->buffer + i; } -- 2.47.3