From 0a954c3f1e837da7f716af0447170db9d09406ee Mon Sep 17 00:00:00 2001 From: Karl Williamson Date: Sun, 27 Apr 2014 10:53:00 -0600 Subject: [PATCH] Optimize /[a-z]/ and /[A-Z]/ These bracketed character classes can easily be optimized into smaller probably faster regops that match identically. --- regcomp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/regcomp.c b/regcomp.c index 4cd50ee..236cb24 100644 --- a/regcomp.c +++ b/regcomp.c @@ -14201,6 +14201,26 @@ parseit: op = POSIXA; } } + else if (prevvalue == 'A') { + if (value == 'Z' +#ifdef EBCDIC + && literal_endpoint == 2 +#endif + ) { + arg = (FOLD) ? _CC_ALPHA : _CC_UPPER; + op = POSIXA; + } + } + else if (prevvalue == 'a') { + if (value == 'z' +#ifdef EBCDIC + && literal_endpoint == 2 +#endif + ) { + arg = (FOLD) ? _CC_ALPHA : _CC_LOWER; + op = POSIXA; + } + } } /* Here, we have changed away from its initial value iff we found -- 1.8.3.1