Skip to content

Commit

Permalink
Iterate over Map entries to avoid extra lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
liblit committed Nov 17, 2024
1 parent cb4d05c commit 50015fa
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.intset.IntegerUnionFind;
import java.util.Map;
import java.util.Map.Entry;
import org.jspecify.annotations.NullUnmarked;
import org.jspecify.annotations.Nullable;

Expand Down Expand Up @@ -119,9 +120,9 @@ private class UnionFind {
private final Object[] allKeys;

private int mapIt(int i, Object[] allVars, Map<Object, V> varMap) {
for (Object key : varMap.keySet()) {
allKeys[i] = key;
allVars[i++] = varMap.get(key);
for (Entry<Object, V> entry : varMap.entrySet()) {
allKeys[i] = entry.getKey();
allVars[i++] = entry.getValue();
}

return i;
Expand Down

0 comments on commit 50015fa

Please sign in to comment.