aboutsummaryrefslogtreecommitdiff
path: root/src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java')
-rw-r--r--src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java73
1 files changed, 50 insertions, 23 deletions
diff --git a/src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java b/src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java
index f7992a32..cc2143de 100644
--- a/src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java
+++ b/src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java
@@ -44,7 +44,7 @@ final class OptExactInfo {
length = 0;
}
- void copy(OptExactInfo other) {
+ void copy(final OptExactInfo other) {
mmd.copy(other.mmd);
anchor.copy(other.anchor);
reachEnd = other.reachEnd;
@@ -54,42 +54,51 @@ final class OptExactInfo {
System.arraycopy(other.chars, 0, chars, 0, OPT_EXACT_MAXLEN);
}
- void concat(OptExactInfo other) {
+ void concat(final OptExactInfo other) {
if (!ignoreCase && other.ignoreCase) {
- if (length >= other.length) return; /* avoid */
+ if (length >= other.length) {
+ return; /* avoid */
+ }
ignoreCase = true;
}
int p = 0; // add->s;
- int end = p + other.length;
+ final int end = p + other.length;
int i;
for (i = length; p < end;) {
- if (i + 1 > OPT_EXACT_MAXLEN) break;
+ if (i + 1 > OPT_EXACT_MAXLEN) {
+ break;
+ }
chars[i++] = other.chars[p++];
}
length = i;
reachEnd = (p == end ? other.reachEnd : false);
- OptAnchorInfo tmp = new OptAnchorInfo();
+ final OptAnchorInfo tmp = new OptAnchorInfo();
tmp.concat(anchor, other.anchor, 1, 1);
- if (!other.reachEnd) tmp.rightAnchor = 0;
+ if (!other.reachEnd) {
+ tmp.rightAnchor = 0;
+ }
anchor.copy(tmp);
}
// ?? raw is not used here
- void concatStr(char[] lchars, int p, int end, boolean raw) {
+ void concatStr(final char[] lchars, final int pp, final int end, final boolean raw) {
int i;
+ int p = pp;
for (i = length; p < end && i < OPT_EXACT_MAXLEN;) {
- if (i + 1 > OPT_EXACT_MAXLEN) break;
+ if (i + 1 > OPT_EXACT_MAXLEN) {
+ break;
+ }
chars[i++] = lchars[p++];
}
length = i;
}
- void altMerge(OptExactInfo other, OptEnvironment env) {
+ void altMerge(final OptExactInfo other, final OptEnvironment env) {
if (other.length == 0 || length == 0) {
clear();
return;
@@ -102,21 +111,27 @@ final class OptExactInfo {
int i;
for (i = 0; i < length && i < other.length; i++) {
- if (chars[i] != other.chars[i]) break;
+ if (chars[i] != other.chars[i]) {
+ break;
+ }
}
- if (!other.reachEnd || i<other.length || i<length) reachEnd = false;
+ if (!other.reachEnd || i<other.length || i<length) {
+ reachEnd = false;
+ }
length = i;
ignoreCase |= other.ignoreCase;
anchor.altMerge(other.anchor);
- if (!reachEnd) anchor.rightAnchor = 0;
+ if (!reachEnd) {
+ anchor.rightAnchor = 0;
+ }
}
- void select(OptExactInfo alt) {
+ void select(final OptExactInfo alt) {
int v1 = length;
int v2 = alt.length;
@@ -130,23 +145,35 @@ final class OptExactInfo {
v2 = OptMapInfo.positionValue(chars[0] & 0xff);
v1 = OptMapInfo.positionValue(alt.chars[0] & 0xff);
- if (length > 1) v1 += 5;
- if (alt.length > 1) v2 += 5;
+ if (length > 1) {
+ v1 += 5;
+ }
+ if (alt.length > 1) {
+ v2 += 5;
+ }
}
- if (!ignoreCase) v1 *= 2;
- if (!alt.ignoreCase) v2 *= 2;
+ if (!ignoreCase) {
+ v1 *= 2;
+ }
+ if (!alt.ignoreCase) {
+ v2 *= 2;
+ }
- if (mmd.compareDistanceValue(alt.mmd, v1, v2) > 0) copy(alt);
+ if (mmd.compareDistanceValue(alt.mmd, v1, v2) > 0) {
+ copy(alt);
+ }
}
// comp_opt_exact_or_map_info
private static final int COMP_EM_BASE = 20;
- int compare(OptMapInfo m) {
- if (m.value <= 0) return -1;
+ int compare(final OptMapInfo m) {
+ if (m.value <= 0) {
+ return -1;
+ }
- int ve = COMP_EM_BASE * length * (ignoreCase ? 1 : 2);
- int vm = COMP_EM_BASE * 5 * 2 / m.value;
+ final int ve = COMP_EM_BASE * length * (ignoreCase ? 1 : 2);
+ final int vm = COMP_EM_BASE * 5 * 2 / m.value;
return mmd.compareDistanceValue(m.mmd, ve, vm);
}