diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-03-09 19:20:36 -0800 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-03-09 19:20:36 -0800 |
commit | 4d1e778aa727abcc6d9b2ab0e39a8348bcb971df (patch) | |
tree | d53116cfe9920b442c2f2016c640372e16d09e82 | |
parent | b7093afaf4bb9fa593d687d6c9646289e8d75cff (diff) |
optimize traverseGeneratedFunctions
-rw-r--r-- | tools/js-optimizer.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 2b9064b2..8df467f8 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -220,12 +220,15 @@ function traverseGenerated(ast, pre, post, stack) { function traverseGeneratedFunctions(ast, callback) { assert(generatedFunctions); - traverse(ast, function(node) { - if (node[0] == 'defun') { - callback(node); - return null; + if (ast[0] == 'toplevel') { + var stats = ast[1]; + for (var i = 0; i < stats.length; i++) { + var curr = stats[i]; + if (curr[0] == 'defun') callback(curr); } - }); + } else if (ast[0] == 'defun') { + callback(ast); + } } // Walk the ast in a simple way, with an understanding of which JS variables are defined) |