On Wed, Nov 11, 2015 at 12:52 PM, Victor Leschuk <[email protected]> wrote:
> "git grep" can now be configured (or told from the command line)
> how many threads to use when searching in the working tree files.
>
> Changes to default behavior: number of threads now doesn't depend
> on online_cpus(), e.g. if specific number is not configured
> GREP_NUM_THREADS_DEFAULT (8) threads will be used even on 1-core CPU.
Why? (I'm asking for an explanation in the commit message so that I
will not have to ask again in future)
> @@ -206,7 +206,8 @@ static void start_threads(struct grep_opt *opt)
> strbuf_init(&todo[i].out, 0);
> }
>
> - for (i = 0; i < ARRAY_SIZE(threads); i++) {
> + threads = xcalloc(num_threads, sizeof(pthread_t));
I think we usually go with sizeof(*threads), but not sure if it's just
a personal taste or the preferred style for git.
> static int grep_cmd_config(const char *var, const char *value, void *cb)
> {
> int st = grep_config(var, value, cb);
> - if (git_color_default_config(var, value, cb) < 0)
> + if (grep_threads_config(var, value, cb) < 0)
> + st = -1;
> + else if (git_color_default_config(var, value, cb) < 0)
> st = -1;
> return st;
Hm... isn't it simpler to just return -1 instead of assigning to st
first? I think you could just merge grep_threads_config() in this
function because it's not that complex to stay separate..
> }
--
Duy
--
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