@@ -292,50 +292,42 @@ static int lastIndexOf(final CharSequence cs, final int searchChar, int start) {
292292 * @return whether the region matched.
293293 * @see String#regionMatches(boolean, int, String, int, int)
294294 */
295- static boolean regionMatches (final CharSequence cs , final boolean ignoreCase , final int thisStart ,
296- final CharSequence substring , final int start , final int length ) {
295+ static boolean regionMatches (final CharSequence cs , final boolean ignoreCase , final int thisStart , final CharSequence substring , final int start ,
296+ final int length ) {
297297 // Green implementation of regionMatches.
298298 if (cs instanceof String && substring instanceof String ) {
299299 return ((String ) cs ).regionMatches (ignoreCase , thisStart , (String ) substring , start , length );
300300 }
301301 int index1 = thisStart ;
302302 int index2 = start ;
303303 int tmpLen = length ;
304-
305304 // Extract these first so we detect NPEs the same as the java.lang.String version
306305 final int srcLen = cs .length () - thisStart ;
307306 final int otherLen = substring .length () - start ;
308-
309307 // Check for invalid parameters
310308 if (thisStart < 0 || start < 0 || length < 0 ) {
311309 return false ;
312310 }
313-
314311 // Check that the regions are long enough
315312 if (srcLen < length || otherLen < length ) {
316313 return false ;
317314 }
318-
319315 while (tmpLen -- > 0 ) {
320316 final char c1 = cs .charAt (index1 ++);
321317 final char c2 = substring .charAt (index2 ++);
322-
323318 if (c1 == c2 ) {
324319 continue ;
325320 }
326-
327321 if (!ignoreCase ) {
328322 return false ;
329323 }
330-
331324 // The real same check as in String#regionMatches(boolean, int, String, int, int):
332325 final char u1 = Character .toUpperCase (c1 );
333326 final char u2 = Character .toUpperCase (c2 );
334327 if (u1 != u2 && Character .toLowerCase (u1 ) != Character .toLowerCase (u2 )) {
335328 return false ;
336329 }
337330 }
338-
339331 return true ;
340332 }
341333
0 commit comments