UI - optimize object allocations#3164
Conversation
…lections to avoid boxing, iterators and improve performance. (Similar change to PointerToPositionMap)
…e dirtyLayers.clear() inside the dirtyLayers.isNotEmpty() check as it does not make sense to clear if dirtyLayers is empty
…hod was iterating over a js value API in a kotlin loop and removing first child. This could cause freezes of up to 50 ms (observed during high-usage memory in a device). I observed a 5.8% reduction in time between main function call and Compose being composed, which amounted to around 7-8 ms (a frame, in my device). Also, the method used has been baseline since 2020 and it is the preferred way as it avoids crossing wasm to Js boundary over and over several times
…nstead Unspecified and Zero versions of it (compiles down to a simple primitive)
…init. (onPointerCallback was being created 6 times on init, delaying scene startup). It also avoid an iterator allocation on init
… from the buildLongSet method instead of the outer extension function, causing the Set to be empty each time
|
Ivan Matkov (@MatkovIvan) separated changes that have nothing to do with graphics (the other changes are blocked until #3126 is merged) to at least unblock them from merging from #3117 |
| * This is used to avoid [Rect] object allocations on hot paths | ||
| */ | ||
| @Stable | ||
| internal inline fun IntSize.contains(offset: Offset): Boolean { |
There was a problem hiding this comment.
it seems semantically wrong - "contains" is not something that we can ask from size.
It might be just naming issues, but I'm not sure what fits better here
There was a problem hiding this comment.
yep, I had the same dichotomy. encloses?? bounds??
if (size.bounds(offset)) bounds being used here as a verb
if (size.encloses(offset)) it is inferred (at least imo) that we are referring to the area between 0,0 and this Size's coordinates
There was a problem hiding this comment.
renamed to bounds and updated KDoc. Done
…th more optimized Collections and more fast paths that avoid allocations
|
I changed the PR title to better reflect the changes |
There was a problem hiding this comment.
LGTM. Oleksandr Karpovich (@eymar), please approve web changes and merge the PR
dbcdcad
into
JetBrains:jb-main
Separated the changes from JetBrains#3117 that don't involve graphics (which are currently blocked until separation of Skiko from Compose Ui and migration to Runtime Registration) as to unblock them from merging into main This includes changes SyntheticEventSender and more minor changes ## Release Notes N/A
Separated the changes from #3117 that don't involve graphics (which are currently blocked until separation of Skiko from Compose Ui and migration to Runtime Registration) as to unblock them from merging into main
This includes changes SyntheticEventSender and more minor changes
Release Notes
N/A