Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use String.equals() in LiteralPathElement #30138

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 + ")";
}

}