aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2020-09-17 00:10:45 +0100
committerGitHub <noreply@github.com>2020-09-17 07:10:45 +0800
commitdd1374aa8adc0a0fc9fec8e173d424e8e1d17041 (patch)
tree45ade3b722a1d99213a6f64616fe3ab523fd6509 /lib
parentfdf2e8c5b079e3977b766c271d61a10cc3ab9947 (diff)
downloadtracifyjs-dd1374aa8adc0a0fc9fec8e173d424e8e1d17041.tar.gz
tracifyjs-dd1374aa8adc0a0fc9fec8e173d424e8e1d17041.zip
minor clean up (#4118)
Diffstat (limited to 'lib')
-rw-r--r--lib/compress.js15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/compress.js b/lib/compress.js
index 89d698da..76be4753 100644
--- a/lib/compress.js
+++ b/lib/compress.js
@@ -4453,7 +4453,12 @@ merge(Compressor.prototype, {
node.value.walk(tw);
mark(node.name, true);
} else {
- declarations.add(node.name.definition().id, node.name);
+ var id = node.name.definition().id;
+ if (!(id in references)) {
+ declarations.add(id, node.name);
+ } else if (references[id]) {
+ references[id].push(node.name);
+ }
}
return true;
}
@@ -4478,11 +4483,6 @@ merge(Compressor.prototype, {
continue;
}
var orig = [], refs = [];
- if (declarations.has(id)) declarations.get(id).forEach(function(sym) {
- sym.thedef = def;
- sym.name = def.name;
- orig.push(sym);
- });
references[id].forEach(function(sym) {
sym.thedef = def;
sym.name = def.name;
@@ -4529,7 +4529,8 @@ merge(Compressor.prototype, {
} else if (self.variables.get(def.name) !== def || compressor.exposed(def)) {
references[def.id] = false;
} else {
- var refs = [ sym ];
+ var refs = declarations.get(def.id) || [];
+ refs.push(sym);
references[def.id] = refs;
if (write_only) {
refs.segment = segment;