summaryrefslogtreecommitdiff
path: root/grep.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-02-28 14:20:53 -0800
committerJunio C Hamano <gitster@pobox.com>2012-02-28 14:29:37 -0800
commit0f871cf56e83d13116b021295688e57f26bbf93d (patch)
treec4b1f607c57ab69aa9d7a17fc690caf4e4dbf67d /grep.c
parentd0482e88a735787f7bb33ef4783be0e7f6a70946 (diff)
downloadgit-0f871cf56e83d13116b021295688e57f26bbf93d.tar.gz
grep: use static trans-case table
In order to prepare the kwset machinery for a case-insensitive search, we used to use a static table of 256 elements and filled it every time before calling kwsalloc(). Because the kwset machinery will never modify this table, just allocate a single instance globally and fill it at the compile time. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'grep.c')
-rw-r--r--grep.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/grep.c b/grep.c
index b29d09c7f6..1030f38f53 100644
--- a/grep.c
+++ b/grep.c
@@ -168,15 +168,10 @@ static void compile_regexp(struct grep_pat *p, struct grep_opt *opt)
p->fixed = 0;
if (p->fixed) {
- if (opt->regflags & REG_ICASE || p->ignore_case) {
- static char trans[256];
- int i;
- for (i = 0; i < 256; i++)
- trans[i] = tolower(i);
- p->kws = kwsalloc(trans);
- } else {
+ if (opt->regflags & REG_ICASE || p->ignore_case)
+ p->kws = kwsalloc(tolower_trans_tbl);
+ else
p->kws = kwsalloc(NULL);
- }
kwsincr(p->kws, p->pattern, p->patternlen);
kwsprep(p->kws);
return;