diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-09-17 00:10:45 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-17 07:10:45 +0800 |
commit | dd1374aa8adc0a0fc9fec8e173d424e8e1d17041 (patch) | |
tree | 45ade3b722a1d99213a6f64616fe3ab523fd6509 /lib | |
parent | fdf2e8c5b079e3977b766c271d61a10cc3ab9947 (diff) | |
download | tracifyjs-dd1374aa8adc0a0fc9fec8e173d424e8e1d17041.tar.gz tracifyjs-dd1374aa8adc0a0fc9fec8e173d424e8e1d17041.zip |
minor clean up (#4118)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/compress.js | 15 |
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; |