Use extend rather than prototype for createFrame

Using prototype has a large performance impact for the common case of a
sparse set of private variable data points. Rather than incurring the
overhead of creating and walking the prototype tree for this, performing
an extend by copy.
This commit is contained in:
kpdecker
2013-08-24 12:10:10 -05:00
parent eb1cda6fdc
commit 0af54b1142
+3 -4
View File
@@ -73,10 +73,9 @@ Handlebars.registerHelper('blockHelperMissing', function(context, options) {
Handlebars.K = function() {};
Handlebars.createFrame = Object.create || function(object) {
Handlebars.K.prototype = object;
var obj = new Handlebars.K();
Handlebars.K.prototype = null;
Handlebars.createFrame = function(object) {
var obj = {};
Handlebars.Utils.extend(obj, object);
return obj;
};