summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2011-01-17 12:36:58 +0100
committerJim Meyering <meyering@redhat.com>2011-01-17 19:07:58 +0100
commitbdaef0686fabc1900c4b3686de17a3ffd9f4d847 (patch)
treebeacc529fd5eb7b408518178eb69b545181f7085 /src
parent1f0653066c58707a210f52164e16bb5561640393 (diff)
downloadcoreutils-bdaef0686fabc1900c4b3686de17a3ffd9f4d847.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/uniq.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/uniq.c b/src/uniq.c
index 9c7e37c7b..b35938a19 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;
}