Skip to content

Commit

Permalink
Merge "Merge cherrypicks of ['android-review.googlesource.com/2821832…
Browse files Browse the repository at this point in the history
…'] into androidx-compose-beta-release." into androidx-compose-beta-release
  • Loading branch information
Android Build Coastguard Worker authored and Gerrit Code Review committed Nov 14, 2023
2 parents a8915c4 + 43b15e0 commit d103e69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions compose/foundation/foundation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ androidXMultiplatform {
commonMain {
dependencies {
implementation(libs.kotlinStdlibCommon)
api(project(':collection:collection'))
api(project(':compose:animation:animation'))
api(project(':compose:runtime:runtime'))
api(project(':compose:ui:ui'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@

package androidx.compose.foundation.lazy.layout

import androidx.collection.MutableObjectIntMap
import androidx.collection.ObjectIntMap
import androidx.collection.emptyObjectIntMap
import androidx.compose.foundation.ExperimentalFoundationApi

/**
Expand Down Expand Up @@ -54,7 +57,7 @@ internal class NearestRangeKeyIndexMap(
nearestRange: IntRange,
intervalContent: LazyLayoutIntervalContent<*>
) : LazyLayoutKeyIndexMap {
private val map: Map<Any, Int>
private val map: ObjectIntMap<Any>
private val keys: Array<Any?>
private val keysStartIndex: Int

Expand All @@ -66,13 +69,14 @@ internal class NearestRangeKeyIndexMap(
check(first >= 0) { "negative nearestRange.first" }
val last = minOf(nearestRange.last, list.size - 1)
if (last < first) {
map = emptyMap()
map = emptyObjectIntMap()
keys = emptyArray()
keysStartIndex = 0
} else {
keys = arrayOfNulls<Any?>(last - first + 1)
val size = last - first + 1
keys = arrayOfNulls<Any?>(size)
keysStartIndex = first
map = hashMapOf<Any, Int>().also { map ->
map = MutableObjectIntMap<Any>(size).also { map ->
list.forEach(
fromIndex = first,
toIndex = last,
Expand Down

0 comments on commit d103e69

Please sign in to comment.