4 ms·
This is why the linked article specifically says it does not look for newlines: > Moreover, GNU grep AVOIDS BREAKING THE INPUT INTO LINES. Looking for newline
by tribaal 8y ago
This is why the linked article specifically says it does not look for newlines:
> Moreover, GNU grep AVOIDS BREAKING THE INPUT INTO LINES. Looking for newlines would slow grep down by a factor of several times, because to find the newlines it would have to look at every byte!
- deleted 8y ago[deleted]
- dllthomas 8y ago... until you ask for line numbers.
- tyingq 8y agoIt can't avoid breaking the output into lines, though, so it probably looks for newlines after a match is found. I assume the Boyer Moore preprocessor reads a lot of bytes also. Not disputing it's more efficient, but there's no magic. It avoids reading some bytes when and if it can.
- dllthomas 8y ago> It can't avoid breaking the output into lines It can whenever you don't ask for line numbers, can't it? > It probably looks for newlines after a match is found Probably, yeah. Counting number of newlines in a range, without caring just where they fall, can probably be pretty darned fast with vector instructions. Idk if that's worth the additional pass, though.