ucs: lch: Reduce garbage objects created for conversions
Triple requires boxing, while DoubleArray allows keeping everything
primitive.
diff --git a/src/commonMain/kotlin/dev/kdrag0n/colorkt/ucs/polar/Lch.kt b/src/commonMain/kotlin/dev/kdrag0n/colorkt/ucs/polar/Lch.kt
index 1646966..36f21fb 100644
--- a/src/commonMain/kotlin/dev/kdrag0n/colorkt/ucs/polar/Lch.kt
+++ b/src/commonMain/kotlin/dev/kdrag0n/colorkt/ucs/polar/Lch.kt
@@ -33,10 +33,10 @@
val h: Double
companion object {
- internal fun Lab.toLch(): Triple<Double, Double, Double> {
+ internal fun Lab.toLch(): DoubleArray {
val hDeg = atan2(b, a).toDegrees()
- return Triple(
+ return doubleArrayOf(
L,
sqrt(a.pow(2) + b.pow(2)),
// Normalize the angle, as many will be negative
@@ -44,10 +44,10 @@
)
}
- internal fun Lch.toLab(): Triple<Double, Double, Double> {
+ internal fun Lch.toLab(): DoubleArray {
val hRad = h.toRadians()
- return Triple(
+ return doubleArrayOf(
L,
C * cos(hRad),
C * sin(hRad),