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

Re: Fix silly typo in new builtin grep

From
Linus Torvalds <torvalds@osdl.org>
Date
May 16, 2006, 03:27 UTC
Message-ID
<Pine.LNX.4.64.0605152008170.3866@g5.osdl.org>
In-Reply-To
<118833cc0605151910s7619ddf0x8f014adba2a1eba5@mail.gmail.com>
On Mon, 15 May 2006, Morten Welinder wrote:
>
> 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.
No, it calls it once per pattern per line.

But yes, it calls it once per line, instead of calling it on some bigger boundary. Partly because of the line-based output, partly probably because regexec() is not actually amenable to a "<buffer,size>" kind of usage, but is based on NUL-terminated strings.

Show 5 quoted lines
> 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.
Yeah, we could do some simple stuff, and see if it helps..
		Linus
Previous: Morten WelinderNext: Junio C Hamano
Message 4 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.