Reviewers: Mads Ager,

Message:
Short review.

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

Please review this at http://codereview.chromium.org/1223006

Affected files:
  M src/string.js


Index: src/string.js
diff --git a/src/string.js b/src/string.js
index e663ec304432f00b71c88765ac4858597e029156..ca438fdde54155d967b77af501ed0724dbdb7b48 100644
--- a/src/string.js
+++ b/src/string.js
@@ -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;
 }




--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

To unsubscribe from this group, send email to v8-dev+unsubscribegooglegroups.com or reply 
to this email with the words "REMOVE ME" as the subject.

Reply via email to