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

Unified Diff: src/string.js

Issue 12316158: Insert conversion to string in string.replace. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 10 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 | test/mjsunit/string-replace.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/string.js
diff --git a/src/string.js b/src/string.js
index 6054e908ae51e655b757e8b1f7be9e39eb608cf2..2f8043c60917a444a77cab71e8af5fb28ca2fa81 100644
--- a/src/string.js
+++ b/src/string.js
@@ -243,6 +243,8 @@ function StringReplace(search, replace) {
%_Log('regexp', 'regexp-replace,%0r,%1S', [search, subject]);
if (!IS_SPEC_FUNCTION(replace)) {
+ replace = TO_STRING_INLINE(replace);
+
if (!search.global) {
// Non-global regexp search, string replace.
var match = DoRegExpExec(search, subject, 0);
@@ -250,7 +252,6 @@ function StringReplace(search, replace) {
search.lastIndex = 0
return subject;
}
- replace = TO_STRING_INLINE(replace);
if (replace.length == 0) {
return %_SubString(subject, 0, match[CAPTURE0]) +
%_SubString(subject, match[CAPTURE1], subject.length)
« no previous file with comments | « no previous file | test/mjsunit/string-replace.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698