Skip to content

Commit f65a3af

Browse files
committed
Fix OrientationIndependentConstraints to reject infinity size
In the OrientationIndependentConstraints, 65535 is infinity. But the class was not reject 65535. This commit fix this bug.
1 parent bb8c0ea commit f65a3af

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

grid/src/commonMain/kotlin/com/cheonjaeung/compose/grid/OrientationIndependentConstraints.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import kotlin.jvm.JvmInline
77

88
private const val Infinity = 0xFFFF
99

10-
private const val MaxSize = Infinity
11-
1210
private const val MainAxisMinSizeBitOffset = 48
1311
private const val MainAxisMaxSizeBitOffset = 32
1412
private const val CrossAxisMinSizeBitOffset = 16
@@ -66,8 +64,8 @@ private fun packOrientationIndependentConstraints(
6664
"minSize must be less than or equal to maxSize"
6765
}
6866

69-
require(mainAxisMaxSizeValue <= MaxSize && crossAxisMaxSizeValue <= MaxSize) {
70-
"size must be less than $MaxSize"
67+
require(mainAxisMaxSizeValue < Infinity && crossAxisMaxSizeValue < Infinity) {
68+
"size must be less than $Infinity"
7169
}
7270

7371
// Pack 4 integer sizes into 64 bits.
@@ -99,7 +97,7 @@ private fun packOrientationIndependentConstraints(
9997
* If the constraints instance is created frequently, it can cause GC pressure and laggy frame.
10098
* For inlining this constraints representation, this class uses a single [Long] to pack and
10199
* represent the four integer sizes: [mainAxisMinSize], [mainAxisMaxSize], [crossAxisMinSize], and
102-
* [crossAxisMaxSize]. Each size is allocated 16 bits, allowing a maximum value of 65534 (2^16 - 1)
100+
* [crossAxisMaxSize]. Each size is allocated 16 bits, allowing a maximum value of 65534
103101
* for each individual constraint component. 65535 is used to represent infinity.
104102
*/
105103
@Immutable

0 commit comments

Comments
 (0)