Commit 356c8ec2 authored by sandholm@chromium.org's avatar sandholm@chromium.org

Improve StringIndexOf.

Review URL: http://codereview.chromium.org/6489028

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6747 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent efe71292
......@@ -103,18 +103,14 @@ function StringConcat() {
// 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;
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);
return %StringIndexOf(subject, TO_STRING_INLINE(pattern), index);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment