aboutsummaryrefslogtreecommitdiff
path: root/tools/js-optimizer.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-12-07 15:07:01 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 15:07:01 -0800
commit73eff601dabda042afcd9d80b4b290d7ca6858fc (patch)
tree444cd52a113a1585d7b251a63819def1a84fbf96 /tools/js-optimizer.js
parent3ee9d95f98391ab27fad70ed91321093febe518d (diff)
simplify normalizeAsm
Diffstat (limited to 'tools/js-optimizer.js')
-rw-r--r--tools/js-optimizer.js11
1 files changed, 5 insertions, 6 deletions
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 78553771..5f21d87d 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -1255,10 +1255,12 @@ function normalizeAsm(func) {
i++;
}
// process initial variable definitions
+ outer:
while (i < stats.length) {
var node = stats[i];
if (node[0] != 'var') break;
- node[1].forEach(function(v) {
+ for (var j = 0; j < node[1].length; j++) {
+ var v = node[1][j];
var name = v[0];
var value = v[1];
if (!(name in data.vars)) {
@@ -1266,12 +1268,9 @@ function normalizeAsm(func) {
data.vars[name] = detectAsmCoercion(value);
v.length = 1; // make an un-assigning var
} else {
- // known var, just an unneeded 'var ' that when removed leaves an assign
- assert(node[1].length == 1);
- node[0] = 'stat';
- node[1] = ['assign', true, ['name', name], value];
+ break outer;
}
- });
+ }
i++;
}
// finally, look for other var definitions and collect them