Skip to content

Commit ca5d7b6

Browse files
committed
Replace Path#reset() with rewind() for faster reuse
1 parent cc55b0b commit ca5d7b6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

extendedspans/src/main/kotlin/me/saket/extendedspans/RoundedCornerSpanPainter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import androidx.compose.ui.geometry.CornerRadius
44
import androidx.compose.ui.geometry.RoundRect
55
import androidx.compose.ui.graphics.Color
66
import androidx.compose.ui.graphics.Path
7+
import androidx.compose.ui.graphics.asAndroidPath
78
import androidx.compose.ui.graphics.drawscope.Fill
89
import androidx.compose.ui.graphics.drawscope.Stroke
910
import androidx.compose.ui.graphics.isUnspecified
@@ -62,7 +63,7 @@ class RoundedCornerSpanPainter(
6263
flattenForFullParagraphs = true
6364
)
6465
boxes.forEachIndexed { index, box ->
65-
path.reset()
66+
path.asAndroidPath().rewind()
6667
path.addRoundRect(
6768
RoundRect(
6869
rect = box.copy(

extendedspans/src/main/kotlin/me/saket/extendedspans/SquigglyUnderlineSpanPainter.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import androidx.compose.ui.graphics.Path
1919
import androidx.compose.ui.graphics.PathEffect
2020
import androidx.compose.ui.graphics.StrokeCap
2121
import androidx.compose.ui.graphics.StrokeJoin
22+
import androidx.compose.ui.graphics.asAndroidPath
2223
import androidx.compose.ui.graphics.drawscope.Stroke
2324
import androidx.compose.ui.graphics.isSpecified
2425
import androidx.compose.ui.text.AnnotatedString
@@ -111,7 +112,7 @@ class SquigglyUnderlineSpanPainter(
111112
)
112113
val textColor = annotation.item.deserializeToColor() ?: layoutResult.layoutInput.style.color
113114
boxes.fastForEach { box ->
114-
path.reset()
115+
path.asAndroidPath().rewind()
115116
path.buildSquigglesFor(box, density = this)
116117
drawPath(
117118
path = path,

0 commit comments

Comments
 (0)