Re: why GNU grep is fast

From: Ed Schouten <ed_at_80386.nl>
Date: Sun, 22 Aug 2010 18:36:44 +0200
* Mike Haertel <mike_at_ducky.net> wrote:
> 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!

I think that implementing a simple fgrep boils down to mmap()ing a file
and calling memmem() on the mapping to search for the input string. Of
course this relies on having an efficient memmem() implementation, for
example using one of the algorithms mentioned in this thread.

-- 
 Ed Schouten <ed_at_80386.nl>
 WWW: http://80386.nl/

Received on Sun Aug 22 2010 - 14:36:45 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:06 UTC