summaryrefslogtreecommitdiffstats
path: root/lib/handlebars/compiler/javascript-compiler.js
diff options
context:
space:
mode:
authorkpdecker <kpdecker@gmail.com>2014-07-06 12:53:01 -0500
committerkpdecker <kpdecker@gmail.com>2014-07-06 12:53:01 -0500
commit4aad72d2230a6eaaf242130c57ad1efa4d701f3c (patch)
tree5ef8394e33ce3206032fe6b256db0b64444af694 /lib/handlebars/compiler/javascript-compiler.js
parent704961b37840a439d6576a0d8f0f595838ab0963 (diff)
downloadhandlebars.js-4aad72d2230a6eaaf242130c57ad1efa4d701f3c.zip
handlebars.js-4aad72d2230a6eaaf242130c57ad1efa4d701f3c.tar.gz
handlebars.js-4aad72d2230a6eaaf242130c57ad1efa4d701f3c.tar.bz2
Move lambda resolution to runtime
This has a very positive impact on precompiled output size, particularly for known-helpers cases, and little or no impact on the throughput numbers.
Diffstat (limited to 'lib/handlebars/compiler/javascript-compiler.js')
-rw-r--r--lib/handlebars/compiler/javascript-compiler.js6
1 files changed, 2 insertions, 4 deletions
diff --git a/lib/handlebars/compiler/javascript-compiler.js b/lib/handlebars/compiler/javascript-compiler.js
index 4b9db92..4d950d4 100644
--- a/lib/handlebars/compiler/javascript-compiler.js
+++ b/lib/handlebars/compiler/javascript-compiler.js
@@ -377,11 +377,9 @@ JavaScriptCompiler.prototype = {
// If the `value` is a lambda, replace it on the stack by
// the return value of the lambda
resolvePossibleLambda: function() {
- this.aliases.functionType = '"function"';
+ this.aliases.lambda = 'this.lambda';
- this.replaceStack(function(current) {
- return "typeof " + current + " === functionType ? " + current + ".apply(depth0) : " + current;
- });
+ this.push('lambda(' + this.popStack() + ', depth0)');
},
// [lookup]