Permalink
Browse files

Small (very small) performance boost

  • Loading branch information...
1 parent a24f715 commit d2e3f490799c5b5f3612cf11f74501fdb0fe5dd8 @akaspin committed Jun 14, 2010
Showing with 14 additions and 12 deletions.
  1. +3 −3 cache.js
  2. +11 −9 compiler.js
View
@@ -5,9 +5,9 @@
//var sys = require("sys");
-cache = {};
-waiters = {};
-needFlush = [];
+var cache = {};
+var waiters = {};
+var needFlush = [];
/**
* Try to get value from cache for key.
View
@@ -2,6 +2,16 @@ var sys = require("sys");
var Script = process.binding('evals').Script;
var HStream = require("./hstream").HStream;
+var bundle = {
+ HStream : HStream,
+ section : section,
+ sectionNormal : sectionNormal,
+ sectionInverted : sectionInverted,
+ lookup : lookup,
+ unescaped : unescaped,
+ process : process
+};
+
/**
* Compile parsed template to native JS function.
* @param stream Parsed template. Represented as Array of
@@ -53,15 +63,7 @@ function compile(stream, callback) {
});
//sys.debug(code+ codeEnd);
- callback(Script.runInNewContext(code + codeEnd,
- {HStream: HStream,
- section: section,
- sectionNormal: sectionNormal,
- sectionInverted: sectionInverted,
- lookup: lookup,
- unescaped: unescaped,
- process: process }
- ));
+ callback(Script.runInNewContext(code + codeEnd, bundle));
}
exports.compile = compile;

0 comments on commit d2e3f49

Please sign in to comment.