MCPcopy Create free account
hub / github.com/google/re2j / maybeConcat

Method maybeConcat

java/com/google/re2j/Parser.java:153–179  ·  view source on GitHub ↗
(int r, int flags)

Source from the content-addressed store, hash-verified

151 // to push r with the given flags.
152 // maybeConcat reports whether r was pushed.
153 private boolean maybeConcat(int r, int flags) {
154 int n = stack.size();
155 if (n < 2) {
156 return false;
157 }
158 Regexp re1 = stack.get(n - 1);
159 Regexp re2 = stack.get(n - 2);
160 if (re1.op != Regexp.Op.LITERAL
161 || re2.op != Regexp.Op.LITERAL
162 || (re1.flags & RE2.FOLD_CASE) != (re2.flags & RE2.FOLD_CASE)) {
163 return false;
164 }
165
166 // Push re1 into re2.
167 re2.runes = concatRunes(re2.runes, re1.runes);
168
169 // Reuse re1 if possible.
170 if (r >= 0) {
171 re1.runes = new int[] {r};
172 re1.flags = flags;
173 return true;
174 }
175
176 pop();
177 reuse(re1);
178 return false; // did not push r
179 }
180
181 // newLiteral returns a new LITERAL Regexp with the given flags
182 private Regexp newLiteral(int r, int flags) {

Callers 2

pushMethod · 0.95
concatMethod · 0.95

Calls 4

concatRunesMethod · 0.95
popMethod · 0.95
reuseMethod · 0.95
getMethod · 0.80

Tested by

no test coverage detected