From 92643d9756bb2d75c27c29229e4e23a8d9fa49ae Mon Sep 17 00:00:00 2001 From: thegrandpoobah Date: Tue, 1 Feb 2011 11:47:12 -0500 Subject: [PATCH] Don't compute object-ness all the time. --- mustache.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mustache.js b/mustache.js index e2a136c..8a50a78 100644 --- a/mustache.js +++ b/mustache.js @@ -755,8 +755,10 @@ var Mustache = function() { var that = this; partials[key] = function(contextStack, send_func) { - var res = that.find_in_stack(key, contextStack); - if (that.is_object(res)) { + var res = that.find_in_stack(key, contextStack), + isObj = that.is_object(res); + + if (isObj) { contextStack.push(res); } @@ -764,7 +766,7 @@ var Mustache = function() { commands[i](contextStack, send_func); } - if (that.is_object(res)) { + if (isObj) { contextStack.pop(); } };