Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(252)

Unified Diff: src/string.js

Issue 18057004: Refactored code a bit to improve StringReplace performance (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/zone.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
===================================================================
--- src/string.js (revision 15496)
+++ src/string.js (working copy)
@@ -184,8 +184,10 @@
var subject = TO_STRING_INLINE(this);
if (IS_REGEXP(regexp)) {
// Emulate RegExp.prototype.exec's side effect in step 5, even though
- // value is discarded.
- ToInteger(regexp.lastIndex);
+ // value is discarded. Inline ToInteger() manually.
+ if (! %_IsSmi(regexp.lastIndex)) {
+ ToNumber(regexp.lastIndex);
+ }
if (!regexp.global) return RegExpExecNoTests(regexp, subject, 0);
%_Log('regexp', 'regexp-match,%0S,%1r', [subject, regexp]);
// lastMatchInfo is defined in regexp.js.
@@ -235,8 +237,10 @@
if (IS_REGEXP(search)) {
// Emulate RegExp.prototype.exec's side effect in step 5, even if
- // value is discarded.
- ToInteger(search.lastIndex);
+ // value is discarded. Inline ToInteger() manually.
+ if (! %_IsSmi(search.lastIndex)) {
+ ToNumber(search.lastIndex);
Yang 2013/07/05 08:10:58 I suggest adding a macro to src/macros.py for this
+ }
%_Log('regexp', 'regexp-replace,%0r,%1S', [search, subject]);
if (!IS_SPEC_FUNCTION(replace)) {
« no previous file with comments | « no previous file | src/zone.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698