1.1 --- a/emul/src/main/java/java/lang/AbstractStringBuilder.java Thu Jan 03 09:14:57 2013 +0100
1.2 +++ b/emul/src/main/java/java/lang/AbstractStringBuilder.java Thu Jan 03 11:11:30 2013 +0100
1.3 @@ -1271,8 +1271,7 @@
1.4 * <code>null</code>.
1.5 */
1.6 public int indexOf(String str, int fromIndex) {
1.7 - return String.indexOf(value, 0, count,
1.8 - str.toCharArray(), 0, str.length(), fromIndex);
1.9 + return toString().indexOf(str, fromIndex);
1.10 }
1.11
1.12 /**
2.1 --- a/emul/src/main/java/java/lang/String.java Thu Jan 03 09:14:57 2013 +0100
2.2 +++ b/emul/src/main/java/java/lang/String.java Thu Jan 03 11:11:30 2013 +0100
2.3 @@ -1769,60 +1769,7 @@
2.4 @JavaScriptBody(args = { "self", "str", "fromIndex" }, body =
2.5 "return self.toString().indexOf(str.toString(), fromIndex);"
2.6 )
2.7 - public int indexOf(String str, int fromIndex) {
2.8 - return indexOf(toCharArray(), offset(), length(), str.toCharArray(), str.offset(), str.length(), fromIndex);
2.9 - }
2.10 -
2.11 - /**
2.12 - * Code shared by String and StringBuffer to do searches. The
2.13 - * source is the character array being searched, and the target
2.14 - * is the string being searched for.
2.15 - *
2.16 - * @param source the characters being searched.
2.17 - * @param sourceOffset offset of the source string.
2.18 - * @param sourceCount count of the source string.
2.19 - * @param target the characters being searched for.
2.20 - * @param targetOffset offset of the target string.
2.21 - * @param targetCount count of the target string.
2.22 - * @param fromIndex the index to begin searching from.
2.23 - */
2.24 - static int indexOf(char[] source, int sourceOffset, int sourceCount,
2.25 - char[] target, int targetOffset, int targetCount,
2.26 - int fromIndex) {
2.27 - if (fromIndex >= sourceCount) {
2.28 - return (targetCount == 0 ? sourceCount : -1);
2.29 - }
2.30 - if (fromIndex < 0) {
2.31 - fromIndex = 0;
2.32 - }
2.33 - if (targetCount == 0) {
2.34 - return fromIndex;
2.35 - }
2.36 -
2.37 - char first = target[targetOffset];
2.38 - int max = sourceOffset + (sourceCount - targetCount);
2.39 -
2.40 - for (int i = sourceOffset + fromIndex; i <= max; i++) {
2.41 - /* Look for first character. */
2.42 - if (source[i] != first) {
2.43 - while (++i <= max && source[i] != first);
2.44 - }
2.45 -
2.46 - /* Found first character, now look at the rest of v2 */
2.47 - if (i <= max) {
2.48 - int j = i + 1;
2.49 - int end = j + targetCount - 1;
2.50 - for (int k = targetOffset + 1; j < end && source[j] ==
2.51 - target[k]; j++, k++);
2.52 -
2.53 - if (j == end) {
2.54 - /* Found whole string. */
2.55 - return i - sourceOffset;
2.56 - }
2.57 - }
2.58 - }
2.59 - return -1;
2.60 - }
2.61 + public native int indexOf(String str, int fromIndex);
2.62
2.63 /**
2.64 * Returns the index within this string of the last occurrence of the
3.1 --- a/emul/src/main/java/java/lang/StringBuffer.java Thu Jan 03 09:14:57 2013 +0100
3.2 +++ b/emul/src/main/java/java/lang/StringBuffer.java Thu Jan 03 11:11:30 2013 +0100
3.3 @@ -527,8 +527,7 @@
3.4 * @since 1.4
3.5 */
3.6 public synchronized int indexOf(String str, int fromIndex) {
3.7 - return String.indexOf(value, 0, count,
3.8 - str.toCharArray(), 0, str.length(), fromIndex);
3.9 + return super.indexOf(str, fromIndex);
3.10 }
3.11
3.12 /**
4.1 --- a/emul/src/main/java/java/lang/StringBuilder.java Thu Jan 03 09:14:57 2013 +0100
4.2 +++ b/emul/src/main/java/java/lang/StringBuilder.java Thu Jan 03 11:11:30 2013 +0100
4.3 @@ -376,8 +376,7 @@
4.4 * @throws NullPointerException {@inheritDoc}
4.5 */
4.6 public int indexOf(String str, int fromIndex) {
4.7 - return String.indexOf(value, 0, count,
4.8 - str.toCharArray(), 0, str.length(), fromIndex);
4.9 + return super.indexOf(str, fromIndex);
4.10 }
4.11
4.12 /**