Re: Fix silly typo in new builtin grep
- From
- Morten Welinder <mwelinder@gmail.com>
- Date
- May 16, 2006, 02:10 UTC
- Message-ID
- <118833cc0605151910s7619ddf0x8f014adba2a1eba5@mail.gmail.com>
- In-Reply-To
- <Pine.LNX.4.64.0605151801100.3866@g5.osdl.org>
If I read the code right, it calls regexec for every single character on every single line. No wonder that takes a while! Just call it once and it'll search for its match quite nicely.
If that's not enough, the two obvious optimizations are...
1. If the pattern contains no regexp characters (and that is very
common), do a strstr.2. If the pattern must start with a specific character, search for that
by itself.M.