Miscellaneous simplifications.
@@ -24,7 +24,9 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.LinkedHashMultimap;
import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
+import com.google.common.collect.Sets;
import com.google.javascript.jscomp.DefinitionsRemover.Definition;
import com.google.javascript.jscomp.DefinitionsRemover.ExternalNameOnlyDefinition;
import com.google.javascript.jscomp.DefinitionsRemover.UnknownDefinition;
@@ -33,8 +35,6 @@ import com.google.javascript.jscomp.NodeTraversal.ChangeScopeRootCallback;
import com.google.javascript.rhino.JSDocInfo;
import com.google.javascript.rhino.Node;
import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -69,12 +69,12 @@ public class NameBasedDefinitionProvider implements DefinitionProvider, Compiler
this.allowComplexFunctionDefs = allowComplexFunctionDefs;
int numInputs = compiler.getNumberOfInputs();
// Estimates below were generated by experimentation with large Google projects.
- // The values are twice as big as we actually expect to need to avoid having any resizing.
- this.definitionsByName = LinkedHashMultimap.create(numInputs * 30, 1);
- int twiceEstimatedDefinitionSites = numInputs * 44;
- this.definitionSitesByDefinitionSiteNode = new LinkedHashMap<>(twiceEstimatedDefinitionSites);
- this.definitionSitesByScopeNode = HashMultimap.create(twiceEstimatedDefinitionSites, 1);
- this.definitionNodes = new HashSet<>(twiceEstimatedDefinitionSites);
+ this.definitionsByName = LinkedHashMultimap.create(numInputs * 15, 1);
+ int estimatedDefinitionSites = numInputs * 22;
+ this.definitionSitesByDefinitionSiteNode =
+ Maps.newLinkedHashMapWithExpectedSize(estimatedDefinitionSites);
+ this.definitionSitesByScopeNode = HashMultimap.create(estimatedDefinitionSites, 1);
+ this.definitionNodes = Sets.newHashSetWithExpectedSize(estimatedDefinitionSites);
}
@Override
