diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2016-09-15 21:45:23 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2016-09-15 21:45:23 -0700 |
commit | 3991f471ecd6095cc321c45dff90955d7108970a (patch) | |
tree | 68fa3a434225d5307ab1be014795d5399d337ee7 | |
parent | 2fea7e5998e4e757d62146e67491ee09f6d1738b (diff) | |
download | txr-3991f471ecd6095cc321c45dff90955d7108970a.tar.gz txr-3991f471ecd6095cc321c45dff90955d7108970a.tar.bz2 txr-3991f471ecd6095cc321c45dff90955d7108970a.zip |
regex: add case to complement optimization.
* regex.c (reg_optimize): Based on the reasoning in the
previous commit, we can also statically optimize a
complement whose argument is the t regex: match nothing.
We convert that to match everything: the .* regex.
Now (regex-compile "~[]") -> #/.*/.
-rw-r--r-- | regex.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -1897,6 +1897,8 @@ static val reg_optimize(val exp) return t; if (arg == nil) return cons(oneplus_s, cons(wild_s, nil)); + if (arg == t) + return cons(zeroplus_s, cons(wild_s, nil)); if (reg_single_char_p(arg)) return list(or_s, list(optional_s, invert_single(arg), nao), |