From: Jim Meyering Date: Mon, 17 Jan 2011 11:36:58 +0000 (+0100) Subject: uniq: replace a wasteful loop with simple calculation X-Git-Tag: v8.10~66 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bdaef0686fabc1900c4b3686de17a3ffd9f4d847;p=thirdparty%2Fcoreutils.git 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. --- 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; }