2 ms·
For line counting specifically, memchr isn't used, but rather, bytecount is: https://docs.rs/bytecount/0.6.2/bytecount/ https://docs.rs/bytecount/0.6.2/bytecoun
by burntsushi 6y ago
For line counting specifically, memchr isn't used, but rather, bytecount is: https://docs.rs/bytecount/0.6.2/bytecount/ https://docs.rs/bytecount/0.6.2/bytecount/
However, memchr is still used for finding the bounds of a line when a match occurs. memchr still does pretty well on shorter haystacks too. The main loop is indeed quite large, but before that, it does unaligned loads of 32 bytes: https://github.com/BurntSushi/rust-memchr/blob/427fdc384007d0a5b00b190e8313b3c8d3694a67/src/x86/avx.rs#L481 https://github.com/BurntSushi/rust-memchr/blob/427fdc384007d...