diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2016-08-14 17:23:38 +0300 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2016-08-14 17:23:38 +0300 |
commit | 8dac7aaa475f205a4fe8ebfd27cd4c75775d6aef (patch) | |
tree | c988fa090a4b3ba46241dde6b5b443def00bb245 | |
parent | 1e83ff34fa8a4a80e486169f24519864480320f4 (diff) | |
download | egawk-8dac7aaa475f205a4fe8ebfd27cd4c75775d6aef.tar.gz egawk-8dac7aaa475f205a4fe8ebfd27cd4c75775d6aef.tar.bz2 egawk-8dac7aaa475f205a4fe8ebfd27cd4c75775d6aef.zip |
Speedup regexp compilation if not using dfa.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | re.c | 12 |
2 files changed, 14 insertions, 4 deletions
@@ -1,3 +1,9 @@ +2016-08-14 Arnold D. Robbins <arnold@skeeve.com> + + * re.c (make_regexp): Only call dfasyntax if actually using + dfa. Gives a 14% speedup on this test: https://raw.githubusercontent.com/chadbrewbaker/awka/master/benchmark/regexp.awk. + From blathering in comp.lang.awk. + 2016-08-12 Arnold D. Robbins <arnold@skeeve.com> * dfa.c: Sync with GNU grep. @@ -203,10 +203,14 @@ make_regexp(const char *s, size_t len, bool ignorecase, bool dfa, bool canfatal) syn &= ~RE_ICASE; } - dfa_syn = syn; - if (ignorecase) - dfa_syn |= RE_ICASE; - dfasyntax(dfa_syn, ignorecase, '\n'); + /* only call dfasyntax if we're using dfa; saves time */ + if (dfa && ! no_dfa) { + dfa_syn = syn; + /* FIXME: dfa doesn't pay attention RE_ICASE */ + if (ignorecase) + dfa_syn |= RE_ICASE; + dfasyntax(dfa_syn, ignorecase, '\n'); + } re_set_syntax(syn); if ((rerr = re_compile_pattern(buf, len, &(rp->pat))) != NULL) { |