Skip to content

Commit

Permalink
Use String.equals() in LiteralPathElement
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzawa-san committed Mar 18, 2023
1 parent 46bd6ad commit d50525d
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class LiteralPathElement extends PathElement {

private final char[] text;

private final String textString;

private final int len;

private final boolean caseSensitive;
Expand All @@ -50,6 +52,7 @@ public LiteralPathElement(int pos, char[] literalText, boolean caseSensitive, ch
this.text[i] = Character.toLowerCase(literalText[i]);
}
}
this.textString = new String(this.text);
}


Expand All @@ -70,10 +73,9 @@ public boolean matches(int pathIndex, MatchingContext matchingContext) {
}

if (this.caseSensitive) {
for (int i = 0; i < this.len; i++) {
if (value.charAt(i) != this.text[i]) {
return false;
}
// This typically uses a JVM intrinsic
if (!this.textString.equals(value)) {
return false;
}
}
else {
Expand Down Expand Up @@ -124,7 +126,7 @@ public boolean isLiteral() {

@Override
public String toString() {
return "Literal(" + String.valueOf(this.text) + ")";
return "Literal(" + this.textString + ")";
}

}

0 comments on commit d50525d

Please sign in to comment.