diff options
author | Jim Meyering <meyering@redhat.com> | 2012-09-13 18:09:49 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2012-09-14 13:34:51 +0200 |
commit | 77f89d014be68e42de5107aee0be95d18ee1735c (patch) | |
tree | 78c3743570816ce0d6be01f958a197968e37b76b /configure.ac | |
parent | 0b4abe7b42a8236f9d75c4e6f9ddb30111b63990 (diff) | |
download | coreutils-77f89d014be68e42de5107aee0be95d18ee1735c.tar.xz |
seq: 70x faster for non-negative whole numbers and incr==1
Handle non-negative whole numbers robustly and efficiently when
the increment is 1 and when no format-changing option is specified.
On the correctness front, for very large numbers, seq now works fine:
$ b=1000000000000000000000000000
$ src/seq ${b}09 ${b}11
100000000000000000000000000009
100000000000000000000000000010
100000000000000000000000000011
while the old one would infloop, printing garbage:
$ seq ${b}09 ${b}11 | head -2
99999999999999999997315645440
99999999999999999997315645440
The new code is much more efficient, too:
Old vs new: 55.81s vs 0.82s
$ env time --f=%e seq $((10**8)) > /dev/null
55.81
$ env time --f=%e src/seq $((10**8)) > /dev/null
0.82
* seq.c (incr): New function, inspired by the one in cat.c.
(cmp, seq_fast): New functions, inspired by code in nt-factor
by Torbjörn Granlund and Niels Möller.
(trim_leading_zeros): New function, without which cmp would malfunction.
(all_digits_p): New function.
(main): Hoist the format_str-vs-equal_width check to precede first
treatment of operands, and insert code to call seq_fast when possible.
* NEWS (Bug fixes): Mention the correctness fix.
(Improvements): Mention the speed-up.
* tests/misc/seq.pl: Exercise the new code.
Improved by: Bernhard Voelker.
http://thread.gmane.org/gmane.comp.gnu.coreutils.general/3340
Diffstat (limited to 'configure.ac')
0 files changed, 0 insertions, 0 deletions