Polish external contribution
This commit removes the text char[] in favor of the text String introduced through the PR. Closes gh-30138
This commit is contained in:
parent
2bc1aa7827
commit
c68e986b75
|
@ -29,9 +29,7 @@ import org.springframework.web.util.pattern.PathPattern.MatchingContext;
|
||||||
*/
|
*/
|
||||||
class LiteralPathElement extends PathElement {
|
class LiteralPathElement extends PathElement {
|
||||||
|
|
||||||
private final char[] text;
|
private final String text;
|
||||||
|
|
||||||
private final String textString;
|
|
||||||
|
|
||||||
private final int len;
|
private final int len;
|
||||||
|
|
||||||
|
@ -42,17 +40,7 @@ class LiteralPathElement extends PathElement {
|
||||||
super(pos, separator);
|
super(pos, separator);
|
||||||
this.len = literalText.length;
|
this.len = literalText.length;
|
||||||
this.caseSensitive = caseSensitive;
|
this.caseSensitive = caseSensitive;
|
||||||
if (caseSensitive) {
|
this.text = new String(literalText);
|
||||||
this.text = literalText;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Force all the text lower case to make matching faster
|
|
||||||
this.text = new char[literalText.length];
|
|
||||||
for (int i = 0; i < this.len; i++) {
|
|
||||||
this.text[i] = Character.toLowerCase(literalText[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.textString = new String(this.text);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,17 +61,13 @@ class LiteralPathElement extends PathElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.caseSensitive) {
|
if (this.caseSensitive) {
|
||||||
// This typically uses a JVM intrinsic
|
if (!this.text.equals(value)) {
|
||||||
if (!this.textString.equals(value)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (int i = 0; i < this.len; i++) {
|
if (!this.text.equalsIgnoreCase(value)) {
|
||||||
// TODO revisit performance if doing a lot of case-insensitive matching
|
return false;
|
||||||
if (Character.toLowerCase(value.charAt(i)) != this.text[i]) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +100,7 @@ class LiteralPathElement extends PathElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char[] getChars() {
|
public char[] getChars() {
|
||||||
return this.text;
|
return this.text.toCharArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,7 +110,7 @@ class LiteralPathElement extends PathElement {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "Literal(" + this.textString + ")";
|
return "Literal(" + this.text + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue