Browse files

optimization to only do a getScope when there is a scopable parent

  • Loading branch information...
1 parent 7aa9f18 commit 7a5118eea58ebeb11b0a292cee9852db1fcf6e96 @substack committed Nov 5, 2012
Showing with 5 additions and 3 deletions.
  1. +5 −3 index.js
View
8 index.js
@@ -39,9 +39,11 @@ module.exports = function (src) {
function lookup (node) {
for (var p = node; p; p = p.parent) {
- var id = getScope(p);
- if (scope[id][node.name]) {
- return id;
+ if (isFunction(p) || p.type === 'Program') {
+ var id = getScope(p);
+ if (scope[id][node.name]) {
+ return id;
+ }
}
}
return '';

0 comments on commit 7a5118e

Please sign in to comment.