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

Method removeLeadingRegexp

java/com/google/re2j/Parser.java:660–683  ·  view source on GitHub ↗
(Regexp re, boolean reuse)

Source from the content-addressed store, hash-verified

658 // If reuse is true, it passes the removed regexp (if no longer needed) to
659 // reuse.
660 private Regexp removeLeadingRegexp(Regexp re, boolean reuse) {
661 if (re.op == Regexp.Op.CONCAT && re.subs.length > 0) {
662 if (reuse) {
663 reuse(re.subs[0]);
664 }
665 re.subs = subarray(re.subs, 1, re.subs.length);
666 switch (re.subs.length) {
667 case 0:
668 re.op = Regexp.Op.EMPTY_MATCH;
669 re.subs = Regexp.EMPTY_SUBS;
670 break;
671 case 1:
672 Regexp old = re;
673 re = re.subs[0];
674 reuse(old);
675 break;
676 }
677 return re;
678 }
679 if (reuse) {
680 reuse(re);
681 }
682 return newRegexp(Regexp.Op.EMPTY_MATCH);
683 }
684
685 private static Regexp literalRegexp(String s, int flags) {
686 Regexp re = new Regexp(Regexp.Op.LITERAL);

Callers 1

factorMethod · 0.95

Calls 3

reuseMethod · 0.95
subarrayMethod · 0.95
newRegexpMethod · 0.95

Tested by

no test coverage detected