Retire Regexp::FactorAlternationRecursive() round 4.
It is redundant: "flattened" bytecode achieves the same result!
Change-Id: I8e54b3945da2a84d5cbb946cff0c1c9ccb6d184f
Reviewed-on: https://code-review.googlesource.com/20730
Reviewed-by: Paul Wankadia <junyer@google.com>
diff --git a/re2/parse.cc b/re2/parse.cc
index c15cc76..a49a6c9 100644
--- a/re2/parse.cc
+++ b/re2/parse.cc
@@ -1082,20 +1082,6 @@
}
n = out;
- // Round 4: Collapse runs of empty matches into single empty match.
- start = 0;
- out = 0;
- for (int i = 0; i < n; i++) {
- if (i + 1 < n &&
- sub[i]->op() == kRegexpEmptyMatch &&
- sub[i+1]->op() == kRegexpEmptyMatch) {
- sub[i]->Decref();
- continue;
- }
- sub[out++] = sub[i];
- }
- n = out;
-
return n;
}
diff --git a/re2/testing/parse_test.cc b/re2/testing/parse_test.cc
index b72429f..4faedb5 100644
--- a/re2/testing/parse_test.cc
+++ b/re2/testing/parse_test.cc
@@ -53,7 +53,7 @@
{ "a{2,3}?", "nrep{2,3 lit{a}}" },
{ "a{2,}?", "nrep{2,-1 lit{a}}" },
{ "", "emp{}" },
- { "|", "emp{}" }, // alt{emp{}emp{}} but got factored
+ { "|", "alt{emp{}emp{}}" },
{ "|x|", "alt{emp{}lit{x}emp{}}" },
{ ".", "dot{}" },
{ "^", "bol{}" },
diff --git a/re2/testing/simplify_test.cc b/re2/testing/simplify_test.cc
index 6bdb2af..43b9656 100644
--- a/re2/testing/simplify_test.cc
+++ b/re2/testing/simplify_test.cc
@@ -125,7 +125,7 @@
// explicit (?:) in place of non-parenthesized empty strings,
// to make them easier to spot for other parsers.
{ "(a|b|)", "([a-b]|(?:))" },
- { "(|)", "()" },
+ { "(|)", "((?:)|(?:))" },
{ "a()", "a()" },
{ "(()|())", "(()|())" },
{ "(a|)", "(a|(?:))" },