On Thu, Apr 11, 2013 at 02:59:32AM +0100, Adam Spiers wrote:
> @@ -111,14 +110,11 @@ static int check_ignore_stdin_paths(struct
> path_exclude_check check, const char
> die("line is badly quoted");
> strbuf_swap(&buf, &nbuf);
> }
> - ALLOC_GROW(pathspec, nr + 1, alloc);
> - pathspec[nr] = xcalloc(strlen(buf.buf) + 1, sizeof(*buf.buf));
> - strcpy(pathspec[nr++], buf.buf);
> + pathspec[0] = xcalloc(strlen(buf.buf) + 1, sizeof(*buf.buf));
> + strcpy(pathspec[0], buf.buf);
> + num_ignored += check_ignore(check, prefix, (const char
> **)pathspec);
> + maybe_flush_or_die(stdout, "check-ignore to stdout");
Now that you are not storing the whole pathspec at once, the pathspec
buffer only needs to be valid for the length of check_ignore, right?
That means you can drop this extra copy and just pass in buf.buf:
pathspec[0] = buf.buf;
num_ignored += check_ignore(check, prefix, pathspec);
> +test_expect_success 'setup: have stdbuf?' '
> + if which stdbuf >/dev/null 2>&1
> + then
> + test_set_prereq STDBUF
> + fi
> +'
Hmm. Today I learned about stdbuf. :)
-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html