Skip to content

Commit 8957947

Browse files
committed
Avoid repeated re-allocations in updateMapWithDeltas
1 parent c3ceb1f commit 8957947

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,18 @@ class TreePickler(pickler: TastyPickler) {
816816
buf.compactify()
817817

818818
def updateMapWithDeltas(mp: MutableSymbolMap[Addr]) =
819-
for (key <- mp.keysIterator.toBuffer[Symbol]) mp(key) = adjusted(mp(key))
819+
val keys = new Array[Symbol](mp.size)
820+
val it = mp.keysIterator
821+
var i = 0
822+
while i < keys.length do
823+
keys(i) = it.next
824+
i += 1
825+
assert(!it.hasNext)
826+
i = 0
827+
while i < keys.length do
828+
val key = keys(i)
829+
mp(key) = adjusted(mp(key))
830+
i += 1
820831

821832
updateMapWithDeltas(symRefs)
822833
}

0 commit comments

Comments
 (0)