diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-06-19 22:38:43 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-06-19 22:38:43 +0300 |
commit | ae7e4d4fedc2237217a9f802eba4ded9ea66bb91 (patch) | |
tree | 6a10111b07939e0013082185ad4d5d471822bf03 /builtin | |
parent | 32e0da583f70fe1406268217befd61e3f515505f (diff) | |
parent | 94da9193a6eb8f1085d611c04ff8bbb4f5ae1e0a (diff) |
Merge branch 'ab/pcre-v2'
Update "perl-compatible regular expression" support to enable JIT
and also allow linking with the newer PCRE v2 library.
* ab/pcre-v2:
grep: add support for PCRE v2
grep: un-break building with PCRE >= 8.32 without --enable-jit
grep: un-break building with PCRE < 8.20
grep: un-break building with PCRE < 8.32
grep: add support for the PCRE v1 JIT API
log: add -P as a synonym for --perl-regexp
grep: skip pthreads overhead when using one thread
grep: don't redundantly compile throwaway patterns under threading
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index d188871556..26d43b4e4c 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -224,7 +224,8 @@ static void start_threads(struct grep_opt *opt) int err; struct grep_opt *o = grep_opt_dup(opt); o->output = strbuf_out; - o->debug = 0; + if (i) + o->debug = 0; compile_grep_patterns(o); err = pthread_create(&threads[i], NULL, run, o); @@ -1170,8 +1171,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) if (!opt.fixed && opt.ignore_case) opt.regflags |= REG_ICASE; - compile_grep_patterns(&opt); - /* * We have to find "--" in a separate pass, because its presence * influences how we will parse arguments that come before it. @@ -1244,12 +1243,23 @@ int cmd_grep(int argc, const char **argv, const char *prefix) num_threads = GREP_NUM_THREADS_DEFAULT; else if (num_threads < 0) die(_("invalid number of threads specified (%d)"), num_threads); + if (num_threads == 1) + num_threads = 0; #else if (num_threads) warning(_("no threads support, ignoring --threads")); num_threads = 0; #endif + if (!num_threads) + /* + * The compiled patterns on the main path are only + * used when not using threading. Otherwise + * start_threads() below calls compile_grep_patterns() + * for each thread. + */ + compile_grep_patterns(&opt); + #ifndef NO_PTHREADS if (num_threads) { if (!(opt.name_only || opt.unmatch_name_only || opt.count) |