Change theme
Help
Press space for more information.
Show links for this issue (Shortcut: i, l)
Copy issue ID
Previous Issue (Shortcut: k)
Next Issue (Shortcut: j)
Sign in to use full features.
Vote: I am impacted
Notification menu
Refresh (Shortcut: Shift+r)
Go home (Shortcut: u)
Pending code changes (auto-populated)
View issue level access limits(Press Alt + Right arrow for more information)
Unintended behavior
View staffing
Description
Component used: collection-ktx Version used: 1.4.0
I'm using MutableLongLongMap to store a map of ids to sizes. The map is fairly large, and I need to increment values several times for many keys.
So I wrote extension functions that look like this:
This works, but if you look at what
updateAndGet()
does under the hood, you'll see that it's callingMutableLongLongMap.findKeyIndex()
to get the value thenMutableLongLongMap.findInsertIndex()
to set the value. Since we know we're going to insert anyway, a better implementation ofupdateAndGet()
could do the hashing & scanning work only once, then get the value (or default), run the update lambda then update the value array.