HomeFreeBSD

wc(1): Extend non-controversial optimizations to '-c' mode

Description

wc(1): Extend non-controversial optimizations to '-c' mode

wc(1)'s slow path for counting words or multibyte characters requires
conversion of the 8-bit input stream to wide characters. However, a faster
path can be used for counting only lines ('-l' -- newlines have the same
representation in all supported encodings) or bytes ('-c').

The existing line count optimization was not used if the input was the
implicit stdin. Additionally, it wasn't used if only byte counting was
requested. This change expands the fast path to both of these scenarios.

Expanding the buffer size from 64 kB helps reduce the number of read(2)
calls needed, but exactly what impact that change has and what size to
expand the buffer to are still under discussion.

PR: 224160
Tested by: wosch (earlier version)
Sponsored by: Dell EMC Isilon

Details

Provenance
cemAuthored on
Parents
rS326735: Define macros used by the pNFS server code.
Branches
Unknown
Tags
Unknown