Index: src/string.js |
diff --git a/src/string.js b/src/string.js |
index 3ddd6d26cedfd9e49a5e624e071f0caeb005fba7..bf1af700b8cd711a354ecc8e9085b06812cc4f3c 100644 |
--- a/src/string.js |
+++ b/src/string.js |
@@ -1031,27 +1031,29 @@ 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(kFirstArgumentNotRegExp, "String.prototype.includes"); |
} |
- var ss = TO_STRING_INLINE(searchString); |
+ var searchString = TO_STRING_INLINE(searchString); |
adamk
2015/07/14 23:24:55
No need for "var" here, you're re-assigning a para
Dan Ehrenberg
2015/07/14 23:45:48
Done.
|
var pos = 0; |
if (%_ArgumentsLength() > 1) { |
pos = %_Arguments(1); // position |
pos = $toInteger(pos); |
adamk
2015/07/14 23:24:55
TO_INTEGER here for more performance
Dan Ehrenberg
2015/07/14 23:45:48
This doesn't affect my benchmark because %_Argumen
|
} |
- var s_len = s.length; |
- var start = MathMin(MathMax(pos, 0), s_len); |
- var ss_len = ss.length; |
- if (ss_len + start > s_len) { |
+ var stringLength = string.length; |
+ if (pos < 0) pos = 0; |
+ if (pos > stringLength) pos = stringLength; |
+ var searchStringLength = searchStringLength.length; |
+ |
+ if (searchStringLength + pos > stringLength) { |
return false; |
} |
- return %StringIndexOf(s, ss, start) !== -1; |
+ return %StringIndexOf(string, searchString, pos) !== -1; |
} |