| Index: src/string.js
|
| ===================================================================
|
| --- src/string.js (revision 6800)
|
| +++ src/string.js (working copy)
|
| @@ -103,17 +103,14 @@
|
| // ECMA-262 section 15.5.4.7
|
| function StringIndexOf(pattern /* position */) { // length == 1
|
| var subject = TO_STRING_INLINE(this);
|
| - var pattern = TO_STRING_INLINE(pattern);
|
| - var subject_len = subject.length;
|
| - var pattern_len = pattern.length;
|
| + pattern = TO_STRING_INLINE(pattern);
|
| var index = 0;
|
| if (%_ArgumentsLength() > 1) {
|
| - var arg1 = %_Arguments(1); // position
|
| - index = TO_INTEGER(arg1);
|
| + index = %_Arguments(1); // position
|
| + index = TO_INTEGER(index);
|
| + if (index < 0) index = 0;
|
| + if (index > subject.length) index = subject.length;
|
| }
|
| - if (index < 0) index = 0;
|
| - if (index > subject_len) index = subject_len;
|
| - if (pattern_len + index > subject_len) return -1;
|
| return %StringIndexOf(subject, pattern, index);
|
| }
|
|
|
| @@ -405,8 +402,7 @@
|
| lastMatchInfoOverride = override;
|
| var func_result =
|
| %_CallFunction(receiver, elem, match_start, subject, replace);
|
| - func_result = TO_STRING_INLINE(func_result);
|
| - res[i] = func_result;
|
| + res[i] = TO_STRING_INLINE(func_result);
|
| match_start += elem.length;
|
| }
|
| i++;
|
| @@ -419,8 +415,7 @@
|
| // Use the apply argument as backing for global RegExp properties.
|
| lastMatchInfoOverride = elem;
|
| var func_result = replace.apply(null, elem);
|
| - func_result = TO_STRING_INLINE(func_result);
|
| - res[i] = func_result;
|
| + res[i] = TO_STRING_INLINE(func_result);
|
| }
|
| i++;
|
| }
|
|
|