--- old/src/share/classes/java/lang/String.java 2014-04-15 19:58:19.556569978 +0400 +++ new/src/share/classes/java/lang/String.java 2014-04-15 19:58:19.116355509 +0400 @@ -1752,6 +1752,10 @@ } char first = target[targetOffset]; + char second = 0; + if (targetCount != 1) { + second = target[targetOffset + 1]; + } int max = sourceOffset + (sourceCount - targetCount); for (int i = sourceOffset + fromIndex; i <= max; i++) { @@ -1759,12 +1763,14 @@ if (source[i] != first) { while (++i <= max && source[i] != first); } - + if (targetCount == 1) { + return (i <= max) ? i - sourceOffset : -1; + } /* Found first character, now look at the rest of v2 */ - if (i <= max) { - int j = i + 1; - int end = j + targetCount - 1; - for (int k = targetOffset + 1; j < end && source[j] + if (i <= max && source[i + 1] == second) { + int j = i + 2; + int end = i + targetCount; + for (int k = targetOffset + 2; j < end && source[j] == target[k]; j++, k++); if (j == end) {