On Wed, Sep 21, 2016 at 08:24:14PM +0200, Johannes Schindelin wrote:
> The new regexec_buf() function operates on buffers with an explicitly
> specified length, rather than NUL-terminated strings.
> We need to use this function whenever the buffer we want to pass to
> regexec() may have been mmap()ed (and is hence not NUL-terminated).
> Note: the original motivation for this patch was to fix a bug where
> `git diff -G <regex>` would crash. This patch converts more callers,
> though, some of which explicitly allocated and constructed
> NUL-terminated strings (or worse: modified read-only buffers to insert
Nice. I probably would have split these into their own patch, but I
think it is OK here.
> @@ -228,18 +227,16 @@ static long ff_regexp(const char *line, long len,
> - line_buffer = xstrndup(line, len); /* make NUL terminated */
Nice to see this one going away in particular, since it's called quite a
lot. According to perf, "git log -p" on git.git drops about 1.5 million
malloc calls (about 9% of the total). And here are best-of-five results
for that same command:
Not a _huge_ improvement, but more significant than the run-to-run