Re: [PATCH] Optimize usage of grep by passing -q

2015-11-17 Thread Jeff King
On Mon, Nov 16, 2015 at 05:04:24PM -0800, Stefan Beller wrote: > >> This is true for the gnu version of grep. I am not sure if all > >> versions of grep support this optimization. In case it is not, > >> we'd revert this patch. > > > > POSIX specifies -q, so you should be fine. > >

[PATCH] Optimize usage of grep by passing -q

2015-11-16 Thread Stefan Beller
Instead of redirecting all grep output to /dev/null, we can just pass in -q instead. This preserves the exit code behavior, but is faster. As grep returns true if it finds at least one match, grep can exit promptly after finding the first line and doesn't need to find more occurrences which would

Re: [PATCH] Optimize usage of grep by passing -q

2015-11-16 Thread Mikael Magnusson
On Mon, Nov 16, 2015 at 10:43 PM, Stefan Beller wrote: > Instead of redirecting all grep output to /dev/null, we can just > pass in -q instead. This preserves the exit code behavior, but is faster. > As grep returns true if it finds at least one match, grep can exit promptly >

Re: [PATCH] Optimize usage of grep by passing -q

2015-11-16 Thread Stefan Beller
+cc Andrey Rybak, who I credit for finding the reasoning below (he sent to me privately, without cc'ing the list) On Mon, Nov 16, 2015 at 4:59 PM, Mikael Magnusson wrote: > On Mon, Nov 16, 2015 at 10:43 PM, Stefan Beller wrote: >> Instead of redirecting