git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Fix silly typo in new builtin grep

From
MWMorten 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.
Previous: Linus TorvaldsNext: Linus Torvalds
Message 3 of 6 in “Fix silly typo in new builtin grep”
  1. Linus TorvaldsMay 16, 2006
  2. Linus TorvaldsMay 16, 2006
  3. Morten WelinderMay 16, 2006
  4. Linus TorvaldsMay 16, 2006
  5. Junio C HamanoMay 16, 2006
  6. Linus TorvaldsMay 16, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.