Skip to content

Commit 2bc1aa7

Browse files
yuzawa-sanpoutsma
authored andcommitted
Use String.equals() in LiteralPathElement
1 parent 570d21e commit 2bc1aa7

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

spring-web/src/main/java/org/springframework/web/util/pattern/LiteralPathElement.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class LiteralPathElement extends PathElement {
3131

3232
private final char[] text;
3333

34+
private final String textString;
35+
3436
private final int len;
3537

3638
private final boolean caseSensitive;
@@ -50,6 +52,7 @@ public LiteralPathElement(int pos, char[] literalText, boolean caseSensitive, ch
5052
this.text[i] = Character.toLowerCase(literalText[i]);
5153
}
5254
}
55+
this.textString = new String(this.text);
5356
}
5457

5558

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

7275
if (this.caseSensitive) {
73-
for (int i = 0; i < this.len; i++) {
74-
if (value.charAt(i) != this.text[i]) {
75-
return false;
76-
}
76+
// This typically uses a JVM intrinsic
77+
if (!this.textString.equals(value)) {
78+
return false;
7779
}
7880
}
7981
else {
@@ -124,7 +126,7 @@ public boolean isLiteral() {
124126

125127
@Override
126128
public String toString() {
127-
return "Literal(" + String.valueOf(this.text) + ")";
129+
return "Literal(" + this.textString + ")";
128130
}
129131

130132
}

0 commit comments

Comments
 (0)