]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cut: optimize -b by avoiding per byte iteration
authorPádraig Brady <P@draigBrady.com>
Sun, 22 Mar 2026 12:20:04 +0000 (12:20 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 5 Apr 2026 12:15:56 +0000 (13:15 +0100)
commita16d56d60c19e180ff987c4f9307bb5eecf0c5cb
tree0e268ee35b573917ff3f4240baf3cf6ee27a4210
parentea6a7ba547ea18302d255b5a4013d0ea2d5d2c88
cut: optimize -b by avoiding per byte iteration

Always memchr(line_delim) which is fast and allows:

- skipping whole segments when the next selected byte is beyond them
- skipping unselected prefixes in bulk
- writing contiguous selected spans in bulk

This wins for lines >= 4 characters,
but is slower lines <= 3 characters, especially if selecting bytes 1-3.
That is unusual though.
src/cut.c