29
29
*/
30
30
class LiteralPathElement extends PathElement {
31
31
32
- private final char [] text ;
33
-
34
- private final String textString ;
32
+ private final String text ;
35
33
36
34
private final int len ;
37
35
@@ -42,17 +40,7 @@ public LiteralPathElement(int pos, char[] literalText, boolean caseSensitive, ch
42
40
super (pos , separator );
43
41
this .len = literalText .length ;
44
42
this .caseSensitive = caseSensitive ;
45
- if (caseSensitive ) {
46
- this .text = literalText ;
47
- }
48
- else {
49
- // Force all the text lower case to make matching faster
50
- this .text = new char [literalText .length ];
51
- for (int i = 0 ; i < this .len ; i ++) {
52
- this .text [i ] = Character .toLowerCase (literalText [i ]);
53
- }
54
- }
55
- this .textString = new String (this .text );
43
+ this .text = new String (literalText );
56
44
}
57
45
58
46
@@ -73,17 +61,13 @@ public boolean matches(int pathIndex, MatchingContext matchingContext) {
73
61
}
74
62
75
63
if (this .caseSensitive ) {
76
- // This typically uses a JVM intrinsic
77
- if (!this .textString .equals (value )) {
64
+ if (!this .text .equals (value )) {
78
65
return false ;
79
66
}
80
67
}
81
68
else {
82
- for (int i = 0 ; i < this .len ; i ++) {
83
- // TODO revisit performance if doing a lot of case-insensitive matching
84
- if (Character .toLowerCase (value .charAt (i )) != this .text [i ]) {
85
- return false ;
86
- }
69
+ if (!this .text .equalsIgnoreCase (value )) {
70
+ return false ;
87
71
}
88
72
}
89
73
@@ -116,7 +100,7 @@ public int getNormalizedLength() {
116
100
117
101
@ Override
118
102
public char [] getChars () {
119
- return this .text ;
103
+ return this .text . toCharArray () ;
120
104
}
121
105
122
106
@ Override
@@ -126,7 +110,7 @@ public boolean isLiteral() {
126
110
127
111
@ Override
128
112
public String toString () {
129
- return "Literal(" + this .textString + ")" ;
113
+ return "Literal(" + this .text + ")" ;
130
114
}
131
115
132
116
}
0 commit comments