Skip to content

Commit

Permalink
Inline non-path context lookups - eliminates a funcall
Browse files Browse the repository at this point in the history
  • Loading branch information
satchmorun committed Feb 8, 2012
1 parent 9126643 commit a6a4628
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions mote.js
Expand Up @@ -561,22 +561,19 @@ Context.prototype.push = function(obj) {

Context.prototype.lookup = function(key) {
var value
, getter = this.isArray(key) ? 'getPath' : 'get'
, node = this;

while (node) {
value = this[getter](node.head, key);
value = this.isArray(key)
? this.getPath(node.head, key)
: (key === '.') ? node.head : node.head[key]
if (value) return value;
node = node.tail;
}

return undefined;
}

Context.prototype.get = function(obj, key) {
return (key === '.') ? obj : obj[key];
};

Context.prototype.getPath = function(obj, key) {
var i = 0
, len = key.length
Expand Down

0 comments on commit a6a4628

Please sign in to comment.