Jovan
11/06/2025, 12:31 PMMap.entries.forEach
and
Map.forEach
Calling entries can be expensive, not sure if second example does the same behind?CLOVIS
11/06/2025, 1:21 PM@kotlin.internal.InlineOnly
public inline operator fun <K, V> Map<out K, V>.iterator(): Iterator<Map.Entry<K, V>> = entries.iterator()
What makes you think using entries is expensive? It's a two object allocations (instead of one for any other iterator), and it's cached between calls for the Java HashMap. Except in very rare cases, it's virtually free.Jovan
11/06/2025, 1:25 PM