]> git.ipfire.org Git - thirdparty/coreutils.git/commit
wc: optimize processing of ASCII in multi byte locales
authorPádraig Brady <P@draigBrady.com>
Fri, 18 May 2018 04:41:46 +0000 (21:41 -0700)
committerPádraig Brady <P@draigBrady.com>
Thu, 21 Jun 2018 04:00:39 +0000 (21:00 -0700)
commit77517a99179b728c6369341b0d36568bac5d7914
tree6e9c69fec2b0ba25f1855b58e02deaf3e3cec2f3
parent21682faa5e9c2f7e1eaa39a938105551b0f000ad
wc: optimize processing of ASCII in multi byte locales

===== Benchmark setup (on GNU/Linux) ====
$ yes áááááááááááááááááááá | head -n100000 > mbc.txt
$ yes 12345678901234567890 | head -n100000 > num.txt

===== Before ====
$ time src/wc -Lm < mbc.txt
real    0m0.186s
$ time src/wc -m < mbc.txt
real    0m0.186s
$ time src/wc -Lm < num.txt
real    0m0.055s
$ time src/wc -m < num.txt
real    0m0.056s

==== After ====
$ time src/wc -Lm < mbc.txt
real    0m0.196s
$ time src/wc -m < mbc.txt
real    0m0.173s
$ time src/wc -Lm < num.txt
real    0m0.031s
$ time src/wc -m < num.txt
real    0m0.028s

* src/wc.c (wc): Only call wide variant functions like
iswprint() and wcwidth() for non is_basic() characters.
I.E. non ISO C "basic character set" characters.
This is especially significant on OSX where wcwidth()
is very expensive (about 10x in tests).
* NEWS: Mention the improvement.
Suggested by Eric Fischer.
NEWS
src/wc.c