Skip to content

Commit

Permalink
Optimize placeable loops using fastForEach
Browse files Browse the repository at this point in the history
  • Loading branch information
cheonjaeung committed Dec 22, 2023
1 parent 960e484 commit 03efe1a
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Density
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.util.fastForEach
import kotlin.math.max
import kotlin.math.min

Expand Down Expand Up @@ -265,10 +266,10 @@ internal class GridMeasureHelper(

val placeableInfoTable = mutableListOf<List<PlaceablePositionInfo>>()
var mainAxisIndex = 0
placeableSpanInfoTable.forEach { placeableLine ->
placeableSpanInfoTable.fastForEach { placeableLine ->
val placeableInfoLine = mutableListOf<PlaceablePositionInfo>()
var crossAxisIndex = 0
placeableLine.forEach { placeableSpanInfo ->
placeableLine.fastForEach { placeableSpanInfo ->
placeableInfoLine.add(
PlaceablePositionInfo(
placeable = placeableSpanInfo.placeable,
Expand Down Expand Up @@ -297,8 +298,8 @@ internal class GridMeasureHelper(
arrangeResult: GridArrangeResult,
) = with(placeableScope) {
val placeableInfoTable = arrangeResult.placeablePositionInfoTable
placeableInfoTable.forEach { placeableInfoLine ->
placeableInfoLine.forEach { placeableInfo ->
placeableInfoTable.fastForEach { placeableInfoLine ->
placeableInfoLine.fastForEach { placeableInfo ->
val placeable = placeableInfo.placeable
if (orientation == LayoutOrientation.Horizontal) {
placeable.place(
Expand Down

0 comments on commit 03efe1a

Please sign in to comment.