Replaced .split("'").join("\\'") with .replace(/'/g, "\\'"). http://jsperf.com/split-join-vs-replace

This commit is contained in:
Ryan W Tenney
2010-09-27 21:55:49 -04:00
parent fbd682d9ec
commit 3505f79566
2 changed files with 13 additions and 13 deletions

View File

@@ -629,7 +629,7 @@
var c = _.templateSettings;
var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
'with(obj||{}){__p.push(\'' +
str.split("'").join("\\'")
str.replace(/'/g, "\\'")
.replace(c.interpolate, function(match, code) {
return "'," + code.replace(/\\'/g, "'") + ",'";
})