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
This commit is contained in:
lrn@chromium.org 2010-03-25 09:09:42 +00:00
parent 64bc213c2a
commit 5f764c82a6

View File

@ -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;
}