diff --git a/extendedspans/src/main/kotlin/me/saket/extendedspans/ExtendedSpans.kt b/extendedspans/src/main/kotlin/me/saket/extendedspans/ExtendedSpans.kt index a317945..837adce 100644 --- a/extendedspans/src/main/kotlin/me/saket/extendedspans/ExtendedSpans.kt +++ b/extendedspans/src/main/kotlin/me/saket/extendedspans/ExtendedSpans.kt @@ -10,9 +10,9 @@ import androidx.compose.ui.text.ExperimentalTextApi import androidx.compose.ui.text.LinkAnnotation import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.text.buildAnnotatedString -import me.saket.extendedspans.internal.fastFold -import me.saket.extendedspans.internal.fastForEach -import me.saket.extendedspans.internal.fastMap +import androidx.compose.ui.util.fastFold +import androidx.compose.ui.util.fastForEach +import androidx.compose.ui.util.fastMap @Stable class ExtendedSpans( diff --git a/extendedspans/src/main/kotlin/me/saket/extendedspans/RoundedCornerSpanPainter.kt b/extendedspans/src/main/kotlin/me/saket/extendedspans/RoundedCornerSpanPainter.kt index 93064fd..6051d36 100644 --- a/extendedspans/src/main/kotlin/me/saket/extendedspans/RoundedCornerSpanPainter.kt +++ b/extendedspans/src/main/kotlin/me/saket/extendedspans/RoundedCornerSpanPainter.kt @@ -12,9 +12,9 @@ import androidx.compose.ui.text.SpanStyle import androidx.compose.ui.text.TextLayoutResult import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.sp +import androidx.compose.ui.util.fastForEach +import androidx.compose.ui.util.fastForEachIndexed import me.saket.extendedspans.internal.deserializeToColor -import me.saket.extendedspans.internal.fastForEach -import me.saket.extendedspans.internal.fastForEachIndexed import me.saket.extendedspans.internal.serialize /** diff --git a/extendedspans/src/main/kotlin/me/saket/extendedspans/SquigglyUnderlineSpanPainter.kt b/extendedspans/src/main/kotlin/me/saket/extendedspans/SquigglyUnderlineSpanPainter.kt index 89cc941..2c49015 100644 --- a/extendedspans/src/main/kotlin/me/saket/extendedspans/SquigglyUnderlineSpanPainter.kt +++ b/extendedspans/src/main/kotlin/me/saket/extendedspans/SquigglyUnderlineSpanPainter.kt @@ -30,10 +30,10 @@ import androidx.compose.ui.text.style.TextDecoration.Companion.Underline import androidx.compose.ui.unit.Density import androidx.compose.ui.unit.TextUnit import androidx.compose.ui.unit.sp -import me.saket.extendedspans.internal.deserializeToColor -import me.saket.extendedspans.internal.fastFirstOrNull -import me.saket.extendedspans.internal.fastForEach +import androidx.compose.ui.util.fastFirstOrNull +import androidx.compose.ui.util.fastForEach import me.saket.extendedspans.internal.fastMapRange +import me.saket.extendedspans.internal.deserializeToColor import me.saket.extendedspans.internal.serialize import kotlin.math.ceil import kotlin.math.sin diff --git a/extendedspans/src/main/kotlin/me/saket/extendedspans/internal/lists.kt b/extendedspans/src/main/kotlin/me/saket/extendedspans/internal/lists.kt index 9d0cdb0..5724751 100644 --- a/extendedspans/src/main/kotlin/me/saket/extendedspans/internal/lists.kt +++ b/extendedspans/src/main/kotlin/me/saket/extendedspans/internal/lists.kt @@ -3,68 +3,6 @@ package me.saket.extendedspans.internal import kotlin.contracts.ExperimentalContracts import kotlin.contracts.contract -/** - * Copied from [androidx](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:text/text/src/main/java/androidx/compose/ui/text/android/TempListUtils.kt;l=33;drc=b2e3d878411b7fb1147455b1a204cddb7bee1a1b). - */ -@OptIn(ExperimentalContracts::class) -internal inline fun List.fastForEach(action: (T) -> Unit) { - contract { callsInPlace(action) } - for (index in indices) { - val item = get(index) - action(item) - } -} - -@OptIn(ExperimentalContracts::class) -internal inline fun List.fastForEachIndexed(action: (index: Int, T) -> Unit) { - contract { callsInPlace(action) } - for (index in indices) { - val item = get(index) - action(index, item) - } -} - -@OptIn(ExperimentalContracts::class) -internal inline fun List.fastFirstOrNull(predicate: (T) -> Boolean): T? { - contract { callsInPlace(predicate) } - for (index in indices) { - val item = get(index) - if (predicate(item)) { - return item - } - } - return null -} - -/** - * Copied from [androidx](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:text/text/src/main/java/androidx/compose/ui/text/android/TempListUtils.kt;l=50;drc=b2e3d878411b7fb1147455b1a204cddb7bee1a1b). - */ -@OptIn(ExperimentalContracts::class) -internal inline fun List.fastMap( - transform: (T) -> R -): List { - contract { callsInPlace(transform) } - val destination = ArrayList(/* initialCapacity = */ size) - fastForEach { item -> - destination.add(transform(item)) - } - return destination -} - -/** - * Copied from [androidx](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose/ui/ui-text/src/commonMain/kotlin/androidx/compose/ui/text/TempListUtils.kt;l=107;drc=ceaa7640c065146360515e598a3d09f6f66553dd). - */ -@Suppress("BanInlineOptIn") // Treat Kotlin Contracts as non-experimental. -@OptIn(ExperimentalContracts::class) -internal inline fun List.fastFold(initial: R, operation: (acc: R, T) -> R): R { - contract { callsInPlace(operation) } - var accumulator = initial - fastForEach { e -> - accumulator = operation(accumulator, e) - } - return accumulator -} - @OptIn(ExperimentalContracts::class) internal inline fun fastMapRange( start: Int,