diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-12-22 11:27:28 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-12-22 11:27:28 -0800 |
commit | ced7469f0700216a05b9ca5b58199f3d761a64e5 (patch) | |
tree | fb6b2eb3a9b9860bb40fc07f37b1f1f3518a200c /builtin | |
parent | adb86762e5535108a9fb4ddc63d2e70cee2038a7 (diff) | |
parent | 53b8d931b649a0d82e16358a6bf1dd980dc24a6b (diff) | |
download | git-ced7469f0700216a05b9ca5b58199f3d761a64e5.tar.gz |
Merge branch 'tr/grep-threading'
* tr/grep-threading:
grep: disable threading in non-worktree case
grep: enable threading with -p and -W using lazy attribute lookup
grep: load funcname patterns for -W
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index 988ea1d332..9ce064ac11 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -17,7 +17,6 @@ #include "grep.h" #include "quote.h" #include "dir.h" -#include "thread-utils.h" static char const * const grep_usage[] = { "git grep [options] [-e] <pattern> [<rev>...] [[--] <path>...]", @@ -256,6 +255,7 @@ static void start_threads(struct grep_opt *opt) pthread_mutex_init(&grep_mutex, NULL); pthread_mutex_init(&read_sha1_mutex, NULL); + pthread_mutex_init(&grep_attr_mutex, NULL); pthread_cond_init(&cond_add, NULL); pthread_cond_init(&cond_write, NULL); pthread_cond_init(&cond_result, NULL); @@ -303,6 +303,7 @@ static int wait_all(void) pthread_mutex_destroy(&grep_mutex); pthread_mutex_destroy(&read_sha1_mutex); + pthread_mutex_destroy(&grep_attr_mutex); pthread_cond_destroy(&cond_add); pthread_cond_destroy(&cond_write); pthread_cond_destroy(&cond_result); @@ -1001,20 +1002,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) if (!opt.fixed && opt.ignore_case) opt.regflags |= REG_ICASE; -#ifndef NO_PTHREADS - if (online_cpus() == 1 || !grep_threads_ok(&opt)) - use_threads = 0; - - if (use_threads) { - if (opt.pre_context || opt.post_context || opt.file_break || - opt.funcbody) - skip_first_line = 1; - start_threads(&opt); - } -#else - use_threads = 0; -#endif - compile_grep_patterns(&opt); /* Check revs and then paths */ @@ -1036,6 +1023,24 @@ int cmd_grep(int argc, const char **argv, const char *prefix) break; } +#ifndef NO_PTHREADS + if (list.nr || cached || online_cpus() == 1) + use_threads = 0; +#else + use_threads = 0; +#endif + + opt.use_threads = use_threads; + +#ifndef NO_PTHREADS + if (use_threads) { + if (opt.pre_context || opt.post_context || opt.file_break || + opt.funcbody) + skip_first_line = 1; + start_threads(&opt); + } +#endif + /* The rest are paths */ if (!seen_dashdash) { int j; |