aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2017-01-19 21:08:19 +0200
committerArnold D. Robbins <arnold@skeeve.com>2017-01-19 21:08:19 +0200
commit5a619e1986724cf8e27b637509925a8da36837e8 (patch)
treeffe527c6bc2bd170ca225d459b74d70cb74dfa70 /io.c
parentbaadccc7297fa9a0cd1bcc276385872fa0ca8b6e (diff)
downloadegawk-5a619e1986724cf8e27b637509925a8da36837e8.tar.gz
egawk-5a619e1986724cf8e27b637509925a8da36837e8.tar.bz2
egawk-5a619e1986724cf8e27b637509925a8da36837e8.zip
Speed up programs that toggle IGNORECASE a lot.
Diffstat (limited to 'io.c')
-rw-r--r--io.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/io.c b/io.c
index 688723fd..d65f2aaa 100644
--- a/io.c
+++ b/io.c
@@ -318,8 +318,7 @@ static long read_default_timeout;
static struct redirect *red_head = NULL;
static NODE *RS = NULL;
-static Regexp *RS_re_yes_case; /* regexp for RS when ignoring case */
-static Regexp *RS_re_no_case; /* regexp for RS when not ignoring case */
+static Regexp *RS_re[2]; /* index 0 - don't ignore case, index 1, do */
static Regexp *RS_regexp;
static const char nonfatal[] = "NONFATAL";
@@ -3870,7 +3869,7 @@ set_RS()
* set_IGNORECASE() relies on this routine to call
* set_FS().
*/
- RS_regexp = (IGNORECASE ? RS_re_no_case : RS_re_yes_case);
+ RS_regexp = RS_re[IGNORECASE];
goto set_FS;
}
unref(save_rs);
@@ -3882,9 +3881,9 @@ set_RS()
* Please do not remerge the if condition; hinders memory deallocation
* in case of fatal error in make_regexp.
*/
- refree(RS_re_yes_case); /* NULL argument is ok */
- refree(RS_re_no_case);
- RS_re_yes_case = RS_re_no_case = RS_regexp = NULL;
+ refree(RS_re[0]); /* NULL argument is ok */
+ refree(RS_re[1]);
+ RS_re[0] = RS_re[1] = RS_regexp = NULL;
if (RS->stlen == 0) {
RS_is_null = true;
@@ -3892,9 +3891,9 @@ set_RS()
} else if (RS->stlen > 1 && ! do_traditional) {
static bool warned = false;
- RS_re_yes_case = make_regexp(RS->stptr, RS->stlen, false, true, true);
- RS_re_no_case = make_regexp(RS->stptr, RS->stlen, true, true, true);
- RS_regexp = (IGNORECASE ? RS_re_no_case : RS_re_yes_case);
+ RS_re[0] = make_regexp(RS->stptr, RS->stlen, false, true, true);
+ RS_re[1] = make_regexp(RS->stptr, RS->stlen, true, true, true);
+ RS_regexp = RS_re[IGNORECASE];
matchrec = rsrescan;