Re: [PATCH 2/5] check-ignore: allow incremental streaming of queries via --stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Apr 11, 2013 at 01:31:45AM -0400, Jeff King wrote:
> 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);

Oops, good point - thanks.  I've made that change.

> > +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. :)

Yeah, it's a relatively recent addition to coreutils.
--
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]