Revision: 4259
Author: [email protected]
Date: Thu Mar 25 02:09:42 2010
Log: Change StringSearch to not call exec and build unnecessary intermediate array.

Review URL: http://codereview.chromium.org/1223006
http://code.google.com/p/v8/source/detail?r=4259

Modified:
 /branches/bleeding_edge/src/string.js

=======================================
--- /branches/bleeding_edge/src/string.js       Tue Mar 23 04:40:38 2010
+++ /branches/bleeding_edge/src/string.js       Thu Mar 25 02:09:42 2010
@@ -522,17 +522,15 @@


 // 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