path: root/grep.h
diff options
authorRené Scharfe <>2009-01-09 23:18:34 (GMT)
committerJunio C Hamano <>2009-01-10 05:35:56 (GMT)
commitc822255cfc1ac83daeeeee1647e3c775450c830c (patch)
treeae2027aed5ead1df39b4da3067300bd80e6cd1bc /grep.h
parentfb62eb7fab97cea880ea7fe4f341a4dfad14ab48 (diff)
grep: don't call regexec() for fixed strings
Add the new flag "fixed" to struct grep_pat and set it if the pattern is doesn't contain any regex control characters in addition to if the flag -F/--fixed-strings was specified. This gives a nice speed up on msysgit, where regexec() seems to be extra slow. Before (best of five runs): $ time git grep grep v1.6.1 >/dev/null real 0m0.552s user 0m0.000s sys 0m0.000s $ time git grep -F grep v1.6.1 >/dev/null real 0m0.170s user 0m0.000s sys 0m0.015s With the patch: $ time git grep grep v1.6.1 >/dev/null real 0m0.173s user 0m0.000s sys 0m0.000s The difference is much smaller on Linux, but still measurable. Signed-off-by: Rene Scharfe <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'grep.h')
1 files changed, 1 insertions, 0 deletions
diff --git a/grep.h b/grep.h
index 45a222d..5102ce3 100644
--- a/grep.h
+++ b/grep.h
@@ -30,6 +30,7 @@ struct grep_pat {
const char *pattern;
enum grep_header_field field;
regex_t regexp;
+ unsigned fixed:1;
enum grep_expr_node {