| Index: src/harmony-string.js
|
| diff --git a/src/harmony-string.js b/src/harmony-string.js
|
| index 6bbe139e87a3a2e96227799fea537261e9f87b51..073ecb14d7975e1dcc4cd8fb82ca619b167dc925 100644
|
| --- a/src/harmony-string.js
|
| +++ b/src/harmony-string.js
|
| @@ -98,28 +98,25 @@ function StringEndsWith(searchString /* position */) { // length == 1
|
| function StringIncludes(searchString /* position */) { // length == 1
|
| CHECK_OBJECT_COERCIBLE(this, "String.prototype.includes");
|
|
|
| - var s = TO_STRING_INLINE(this);
|
| + var string = TO_STRING_INLINE(this);
|
|
|
| if (IS_REGEXP(searchString)) {
|
| throw MakeTypeError("first_argument_not_regexp",
|
| ["String.prototype.includes"]);
|
| }
|
|
|
| - var ss = TO_STRING_INLINE(searchString);
|
| - var pos = 0;
|
| - if (%_ArgumentsLength() > 1) {
|
| - pos = %_Arguments(1); // position
|
| - pos = ToInteger(pos);
|
| - }
|
| + searchString = TO_STRING_INLINE(searchString);
|
|
|
| - var s_len = s.length;
|
| - var start = MathMin(MathMax(pos, 0), s_len);
|
| - var ss_len = ss.length;
|
| - if (ss_len + start > s_len) {
|
| - return false;
|
| - }
|
| + var pos = ToInteger(%_Arguments(1));
|
| + var len = string.length;
|
| + var searchLength = searchString.length;
|
| +
|
| + if (pos < 0) pos = 0;
|
| + else if (pos > len) pos = len;
|
| +
|
| + if (searchLength + pos > len) return false;
|
|
|
| - return %StringIndexOf(s, ss, start) !== -1;
|
| + return %StringIndexOf(string, searchString, pos) !== -1;
|
| }
|
|
|
|
|
|
|