Conversation
|
This PR looks reasonable. Can you please make this additional change? --- a/lib/compress.js
+++ b/lib/compress.js
@@ -1413,7 +1413,7 @@ merge(Compressor.prototype, {
&& !self.uses_with
) {
var in_use = [];
- var in_use_ids = {}; // avoid expensive linear scans of in_use
+ var in_use_ids = Object.create(null); // avoid expensive linear scans of in_use
var initializations = new Dictionary();
// pass 1: find out which symbols are directly used in
// this scope (not in nested scopes).Lookups may be faster due to no proto chain, and It corrects a potential hasOwnProperty issue. |
|
Would you like to move that same-line comment as well? |
|
If we use |
The code's pretty dense there. I think the trailing comment is okay in that case.
I'm not sure it would be faster without some empirical evidence. It will likely be the same speed. There's a chance it could be slower since a value is being returned. Can we leave it as is since I know it works? |
|
|
- utilise in_use_ids instead of unreferenced() - drop_unused now up-to-date for subsequent passes
20cbcf3 to
cd167d1
Compare
- utilise in_use_ids instead of unreferenced() - drop_unused now up-to-date for subsequent passes closes mishoo#1476
AST_Symbol.unreferenced()is based onSymbolDef.referencesarray which is populated duringAST_Toplevel.figure_out_scope()beforeCompressoris used.As a result, there are corner cases which
!keep_fnamesand!keep_fargswon't be able to give the best solution. As we already do a thorough usage scan inAST_Scope.drop_unused(), we might as well perform the optimisation steps over there instead.