Skip to content

Commit 20c659b

Browse files
committed
Undo some recent changes in RECompiled
- Do not store source string - Remove unused methods
1 parent bcb8708 commit 20c659b

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

src/org/mozilla/javascript/regexp/NativeRegExp.java

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1391,11 +1391,13 @@ private static int getIndex(byte[] array, int pc)
13911391
{
13921392
if ((gData.cp + length) > end)
13931393
return false;
1394-
if (input.regionMatches(gData.cp, gData.regexp.sourceString, matchChars, length)) {
1395-
gData.cp += length;
1396-
return true;
1394+
for (int i = 0; i < length; i++) {
1395+
if (gData.regexp.source[matchChars + i] != input.charAt(gData.cp + i)) {
1396+
return false;
1397+
}
13971398
}
1398-
return false;
1399+
gData.cp += length;
1400+
return true;
13991401
}
14001402

14011403
private static boolean
@@ -2758,7 +2760,6 @@ class RECompiled implements Serializable
27582760
static final long serialVersionUID = -6144956577595844213L;
27592761

27602762
final char[] source; /* locked source string, sans // */
2761-
final String sourceString;
27622763
int parenCount; /* number of parenthesized submatches */
27632764
int flags; /* flags */
27642765
byte[] program; /* regular expression bytecode */
@@ -2767,21 +2768,8 @@ class RECompiled implements Serializable
27672768
int anchorCh = -1; /* if >= 0, then re starts with this literal char */
27682769

27692770
RECompiled(String str) {
2770-
this.sourceString = str;
27712771
this.source = str.toCharArray();
27722772
}
2773-
2774-
public int flags() {
2775-
return flags;
2776-
}
2777-
2778-
public String source() {
2779-
return sourceString;
2780-
}
2781-
2782-
public int parenCount() {
2783-
return parenCount;
2784-
}
27852773
}
27862774

27872775
class RENode {

0 commit comments

Comments
 (0)