diff --git a/src/com/google/javascript/jscomp/Es6RenameVariablesInParamLists.java b/src/com/google/javascript/jscomp/Es6RenameVariablesInParamLists.java index adf7ad6881e..21ba3d62a0d 100644 --- a/src/com/google/javascript/jscomp/Es6RenameVariablesInParamLists.java +++ b/src/com/google/javascript/jscomp/Es6RenameVariablesInParamLists.java @@ -22,7 +22,7 @@ import com.google.javascript.jscomp.parsing.parser.FeatureSet; import com.google.javascript.jscomp.parsing.parser.FeatureSet.Feature; import com.google.javascript.rhino.Node; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; @@ -94,7 +94,7 @@ public void process(Node externs, Node root) { /** Collects all references in a naive way. */ private static class CollectReferences { - private final Set currFuncReferences = new HashSet<>(); + private final Set currFuncReferences = new LinkedHashSet<>(); void collect(Node fn) { checkState(fn.isFunction()); diff --git a/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java b/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java index b5086b92dfb..c439854daf6 100644 --- a/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java +++ b/src/com/google/javascript/jscomp/Es6RewriteBlockScopedDeclaration.java @@ -34,7 +34,6 @@ import com.google.javascript.rhino.JSDocInfo; import com.google.javascript.rhino.Node; import com.google.javascript.rhino.Token; -import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.Map; @@ -56,9 +55,9 @@ public final class Es6RewriteBlockScopedDeclaration extends AbstractPostOrderCal private final AbstractCompiler compiler; private final AstFactory astFactory; private final Table renameTable = HashBasedTable.create(); - private final Set letConsts = new HashSet<>(); - private final Set undeclaredNames = new HashSet<>(); - private final Set externNames = new HashSet<>(); + private final Set letConsts = new LinkedHashSet<>(); + private final Set undeclaredNames = new LinkedHashSet<>(); + private final Set externNames = new LinkedHashSet<>(); private static final FeatureSet transpiledFeatures = FeatureSet.BARE_MINIMUM.with(Feature.LET_DECLARATIONS, Feature.CONST_DECLARATIONS); private final Supplier uniqueNameIdSupplier; diff --git a/src/com/google/javascript/jscomp/Es6RewriteGenerators.java b/src/com/google/javascript/jscomp/Es6RewriteGenerators.java index ab13da82e62..07e35e6ae83 100644 --- a/src/com/google/javascript/jscomp/Es6RewriteGenerators.java +++ b/src/com/google/javascript/jscomp/Es6RewriteGenerators.java @@ -37,6 +37,8 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import org.jspecify.nullness.Nullable; /** @@ -1122,13 +1124,13 @@ private boolean isEndOfBlockUnreachable(Node block) { /** State machine context that is used during generator function transpilation. */ private class TranspilationContext { - final HashMap namedLabels = new HashMap<>(); + final HashMap namedLabels = new LinkedHashMap<>(); final ArrayDeque breakCases = new ArrayDeque<>(); final ArrayDeque continueCases = new ArrayDeque<>(); final ArrayDeque catchCases = new ArrayDeque<>(); final ArrayDeque finallyCases = new ArrayDeque<>(); - final HashSet catchNames = new HashSet<>(); + final HashSet catchNames = new LinkedHashSet<>(); /** All "case" sections that will be added to generator program. */ final ArrayList allCases = new ArrayList<>(); diff --git a/src/com/google/javascript/jscomp/ParenthesizeFunctionsInChunks.java b/src/com/google/javascript/jscomp/ParenthesizeFunctionsInChunks.java index 8495051ae7c..e4ae7b9e0b2 100644 --- a/src/com/google/javascript/jscomp/ParenthesizeFunctionsInChunks.java +++ b/src/com/google/javascript/jscomp/ParenthesizeFunctionsInChunks.java @@ -27,7 +27,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Deque; -import java.util.HashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -86,7 +86,7 @@ private static class Traversal implements NodeTraversal.Callback { private final ListMultimap hoistNodesToScope = ArrayListMultimap.create(); // Map for recording diagnostic information about what was marked for eager compilation. - private final Map chunkToEagerCompileFnCounts = new HashMap<>(); + private final Map chunkToEagerCompileFnCounts = new LinkedHashMap<>(); public Traversal(Set parenthesizeFunctionsInChunks) { this.parenthesizeFunctionsInChunks = parenthesizeFunctionsInChunks; diff --git a/src/com/google/javascript/jscomp/VariableReferenceCheck.java b/src/com/google/javascript/jscomp/VariableReferenceCheck.java index db82b916eb5..263c83f3fc9 100644 --- a/src/com/google/javascript/jscomp/VariableReferenceCheck.java +++ b/src/com/google/javascript/jscomp/VariableReferenceCheck.java @@ -25,7 +25,7 @@ import com.google.javascript.rhino.Node; import com.google.javascript.rhino.QualifiedName; import com.google.javascript.rhino.Token; -import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import org.jspecify.nullness.Nullable; @@ -79,7 +79,7 @@ class VariableReferenceCheck implements CompilerPass { // NOTE(nicksantos): It's a lot faster to use a shared Set that // we clear after each method call, because the Set never gets too big. - private final Set blocksWithDeclarations = new HashSet<>(); + private final Set blocksWithDeclarations = new LinkedHashSet<>(); // These types do not permit a block-scoped declaration inside them without an explicit block. // e.g. if (b) let x; @@ -112,7 +112,7 @@ private class ReferenceCheckingBehavior implements Behavior { private final Set varsInFunctionBody; private ReferenceCheckingBehavior() { - varsInFunctionBody = new HashSet<>(); + varsInFunctionBody = new LinkedHashSet<>(); } @Override