@@ -41,15 +41,16 @@ private void removeCycles(List<List<ImFunction>> components) {
4141 for (List <ImFunction > component : components ) {
4242 if (component .size () > 1 ) {
4343 // keep list for order; set for O(1) membership
44- Set <ImFunction > funcSet = new HashSet <>(component );
44+ Set <ImFunction > funcSet = Collections .newSetFromMap (new IdentityHashMap <>());
45+ funcSet .addAll (component );
4546 removeCycle (component , funcSet );
4647 }
4748 }
4849 }
4950
5051 private void removeCycle (List <ImFunction > funcs , Set <ImFunction > funcSet ) {
5152 List <ImVar > newParameters = Lists .newArrayList ();
52- Map <ImVar , ImVar > oldToNewVar = Maps . newLinkedHashMap ();
53+ Map <ImVar , ImVar > oldToNewVar = new IdentityHashMap <> ();
5354
5455 calculateNewParameters (funcs , newParameters , oldToNewVar );
5556
@@ -90,11 +91,11 @@ private void removeCycle(List<ImFunction> funcs, Set<ImFunction> funcSet) {
9091 stmts = elseBlock ;
9192 }
9293
93- Map <ImFunction , Integer > funcToIndex = new HashMap <>();
94+ Map <ImFunction , Integer > funcToIndex = new IdentityHashMap <>();
9495 for (int i = 0 ; i < funcs .size (); i ++) {
9596 funcToIndex .put (funcs .get (i ), i );
9697 }
97- Map <ImFunction , ImFunction > proxyByOriginal = new HashMap <>();
98+ Map <ImFunction , ImFunction > proxyByOriginal = new IdentityHashMap <>();
9899 // Rewrite only affected roots:
99100 // - merged cycle body (contains moved bodies from all old funcs)
100101 // - callers that directly call any removed function
@@ -107,8 +108,8 @@ private void removeCycle(List<ImFunction> funcs, Set<ImFunction> funcSet) {
107108 }
108109 for (ImFunction caller : new ArrayList <>(tr .getCalledFunctions ().keySet ())) {
109110 Collection <ImFunction > called = tr .getCalledFunctions ().get (caller );
110- for (ImFunction removed : funcSet ) {
111- if (called .contains (removed )) {
111+ for (ImFunction c : called ) {
112+ if (funcSet .contains (c )) {
112113 rewriteRoots .add (caller .getBody ());
113114 break ;
114115 }
0 commit comments