Method
indexOf
(CharSequence haystack, CharSequence needle, int start)
Source from the content-addressed store, hash-verified
| 93 | } |
| 94 | |
| 95 | static int indexOf(CharSequence haystack, CharSequence needle, int start) { |
| 96 | if (needle.length() == 0) return start; |
| 97 | |
| 98 | for (int i = start; i < haystack.length() - needle.length() + 1; ++i) { |
| 99 | int j = 0; |
| 100 | for (; j < needle.length(); ++j) { |
| 101 | if (haystack.charAt(i + j) != needle.charAt(j)) { |
| 102 | break; |
| 103 | } |
| 104 | } |
| 105 | if (j == needle.length()) { |
| 106 | return i; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | return -1; |
| 111 | } |
| 112 | } |
Tested by
no test coverage detected