Commit 5f764c82 authored by lrn@chromium.org's avatar lrn@chromium.org

Change StringSearch to not call exec and build unnecessary intermediate array.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@4259 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 64bc213c
......@@ -522,17 +522,15 @@ function ApplyReplacementFunction(replace, matchInfo, subject) {
// ECMA-262 section 15.5.4.12
function StringSearch(re) {
function StringSearch(re) {
var regexp = new $RegExp(re);
var s = TO_STRING_INLINE(this);
var last_idx = regexp.lastIndex; // keep old lastIndex
regexp.lastIndex = 0; // ignore re.global property
var result = regexp.exec(s);
regexp.lastIndex = last_idx; // restore lastIndex
if (result == null)
return -1;
else
return result.index;
var match = DoRegExpExec(regexp, s, 0);
if (match) {
lastMatchInfo = match;
return match[CAPTURE0];
}
return -1;
}
......
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