MCPcopy Create free account
hub / github.com/google/re2j / equalsIgnoreCase

Method equalsIgnoreCase

java/com/google/re2j/Unicode.java:131–160  ·  view source on GitHub ↗
(int r1, int r2)

Source from the content-addressed store, hash-verified

129 // to compare it to |r2|.
130 // -1 is interpreted as the end-of-file mark.
131 static boolean equalsIgnoreCase(int r1, int r2) {
132 // Runes already match, or one of them is EOF
133 if (r1 < 0 || r2 < 0 || r1 == r2) {
134 return true;
135 }
136
137 // Fast path for the common case where both runes are ASCII characters.
138 // Coerces both runes to lowercase if applicable.
139 if (r1 <= MAX_ASCII && r2 <= MAX_ASCII) {
140 if ('A' <= r1 && r1 <= 'Z') {
141 r1 |= 0x20;
142 }
143
144 if ('A' <= r2 && r2 <= 'Z') {
145 r2 |= 0x20;
146 }
147
148 return r1 == r2;
149 }
150
151 // Fall back to full Unicode case folding otherwise.
152 // Invariant: r1 must be non-negative
153 for (int r = Unicode.simpleFold(r1); r != r1; r = Unicode.simpleFold(r)) {
154 if (r == r2) {
155 return true;
156 }
157 }
158
159 return false;
160 }
161
162 private Unicode() {} // uninstantiable
163}

Callers 2

testEqualsIgnoreCaseMethod · 0.95
matchRuneMethod · 0.95

Calls 1

simpleFoldMethod · 0.95

Tested by 1

testEqualsIgnoreCaseMethod · 0.76