1.1 --- a/emul/src/main/java/java/lang/String.java Fri Jan 11 16:07:55 2013 +0100
1.2 +++ b/emul/src/main/java/java/lang/String.java Fri Jan 11 16:36:28 2013 +0100
1.3 @@ -1769,60 +1769,7 @@
1.4 @JavaScriptBody(args = { "self", "str", "fromIndex" }, body =
1.5 "return self.toString().indexOf(str.toString(), fromIndex);"
1.6 )
1.7 - public int indexOf(String str, int fromIndex) {
1.8 - return indexOf(toCharArray(), offset(), length(), str.toCharArray(), str.offset(), str.length(), fromIndex);
1.9 - }
1.10 -
1.11 - /**
1.12 - * Code shared by String and StringBuffer to do searches. The
1.13 - * source is the character array being searched, and the target
1.14 - * is the string being searched for.
1.15 - *
1.16 - * @param source the characters being searched.
1.17 - * @param sourceOffset offset of the source string.
1.18 - * @param sourceCount count of the source string.
1.19 - * @param target the characters being searched for.
1.20 - * @param targetOffset offset of the target string.
1.21 - * @param targetCount count of the target string.
1.22 - * @param fromIndex the index to begin searching from.
1.23 - */
1.24 - static int indexOf(char[] source, int sourceOffset, int sourceCount,
1.25 - char[] target, int targetOffset, int targetCount,
1.26 - int fromIndex) {
1.27 - if (fromIndex >= sourceCount) {
1.28 - return (targetCount == 0 ? sourceCount : -1);
1.29 - }
1.30 - if (fromIndex < 0) {
1.31 - fromIndex = 0;
1.32 - }
1.33 - if (targetCount == 0) {
1.34 - return fromIndex;
1.35 - }
1.36 -
1.37 - char first = target[targetOffset];
1.38 - int max = sourceOffset + (sourceCount - targetCount);
1.39 -
1.40 - for (int i = sourceOffset + fromIndex; i <= max; i++) {
1.41 - /* Look for first character. */
1.42 - if (source[i] != first) {
1.43 - while (++i <= max && source[i] != first);
1.44 - }
1.45 -
1.46 - /* Found first character, now look at the rest of v2 */
1.47 - if (i <= max) {
1.48 - int j = i + 1;
1.49 - int end = j + targetCount - 1;
1.50 - for (int k = targetOffset + 1; j < end && source[j] ==
1.51 - target[k]; j++, k++);
1.52 -
1.53 - if (j == end) {
1.54 - /* Found whole string. */
1.55 - return i - sourceOffset;
1.56 - }
1.57 - }
1.58 - }
1.59 - return -1;
1.60 - }
1.61 + public native int indexOf(String str, int fromIndex);
1.62
1.63 /**
1.64 * Returns the index within this string of the last occurrence of the