On Mon, 11 Jan 2010, Fredrik Kuivinen wrote: > > Another option is to use memmem instead. As we know the length of the > buffer already it should be a slight improvement over strstr for > everyone. memmem may cause some portability problems though as it is a > GNU extension. I'd almost prefer to just drop the strstr entirely. It's not actually all *that* big a win, even on my machine. I get - strstr: real 0m0.309s user 0m0.168s sys 0m0.136s - regexec: real 0m0.410s user 0m0.220s sys 0m0.116s so yeah, it's slower, but not by a huge degree. With strstr, "git grep" actually beats the external grep for me, but I don't really care. It's already way better than it used to be - and clearly strstr has a lot of potential problems. Sure memmem() might be better for you than strstr, but on the other hand, it might easily be worse than strstr for others - and not just from a portability standpoint. Is memmem() optimized to take advantage of SSE4.2? I suspect it is not, exactly _because_ it's a GNU extension, so Intel hasn't published optimized sample code for people to use. So I would argue against even bothering to try memmem. Especially since in your case, regexec() is apparently faster than memmem _anyway_. I expect that it is for me too, but I'm too lazy to check. Linus -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html