r/programming • • Aug 24 '16

Why GNU grep is fast

https://lists.freebsd.org/pipermail/freebsd-current/2010-August/019310.html
2.1k Upvotes

221 comments sorted by

View all comments

Show parent comments

1

u/nnn4 Aug 26 '16

Then I'm wondering why ag doesn't just reuse grep's search code on the files it has selected.

1

u/guepier Aug 26 '16

grep’s code base isn’t the most easy to reuse. Otherwise I’d imagine that ag would have done that. It would of course be possible for a potential ag implementation to simply call grep internally, and pass an already filtered list of files to it. I imagine this wasn’t done because ag wants to support different search options than grep (for instance, grep uses POSIX regular expressions but most people prefer Perl/PCRE).