diff options
author | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2022-09-02 15:21:41 +0000 |
---|---|---|
committer | Scott Soule Cheloha <cheloha@cvs.openbsd.org> | 2022-09-02 15:21:41 +0000 |
commit | 9704a5ae033ca6d3e4d9ab336aa342fbc1199b49 (patch) | |
tree | 2572c61eee83fdbbced034b46a59255aeefd26b9 /etc | |
parent | 042e2a8dece79ddc2d9f17b5d9351886cfc299ab (diff) |
wc(1): accelerate word counting
wc(1) counts a word whenever a whitespace byte is followed by a
non-whitespace byte. Because the state machine transition occurs
within the space of a single byte we don't need to use getline(3).
Counting words in a big buffer with read(2) is much faster. The
overhead varies with the length of a line, but for files with 60-100
byte lines, word counting is about twice as fast when we avoid
getline(3). In the pathological case where each line is a single
byte, word counting is about ten times as fast when we avoid
getline(3).
Link1: https://marc.info/?l=openbsd-tech&m=163715995626532&w=2
Link2: https://marc.info/?l=openbsd-tech&m=165956826103639&w=2
"Seems reasonable." deraadt@
Diffstat (limited to 'etc')
0 files changed, 0 insertions, 0 deletions