From 75bba098a2b9c1151d95a232d3270c1cab0cb8d7 Mon Sep 17 00:00:00 2001 From: Edwin Jakobs Date: Sun, 2 Feb 2025 11:41:19 +0100 Subject: [PATCH] [orxy-shape] Optimize list initialization with predefined capacity in HobbyCurve.kt --- orx-shapes/src/commonMain/kotlin/hobbycurve/HobbyCurve.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/orx-shapes/src/commonMain/kotlin/hobbycurve/HobbyCurve.kt b/orx-shapes/src/commonMain/kotlin/hobbycurve/HobbyCurve.kt index 0fd3a378..3a29a628 100644 --- a/orx-shapes/src/commonMain/kotlin/hobbycurve/HobbyCurve.kt +++ b/orx-shapes/src/commonMain/kotlin/hobbycurve/HobbyCurve.kt @@ -109,8 +109,8 @@ fun hobbyCurve(points: List, closed: Boolean = false, curl: Double = 0. } } - val c1s = mutableListOf() - val c2s = mutableListOf() + val c1s = ArrayList(n) + val c2s = ArrayList(n) for (i in 0 until n) { val v1 = rotateAngle(chords[i], alpha[i]).normalized val v2 = rotateAngle(chords[i], -beta[i]).normalized @@ -205,8 +205,8 @@ fun hobbyCurve( } } - val c1s = mutableListOf() - val c2s = mutableListOf() + val c1s = ArrayList(n) + val c2s = ArrayList(n) for (i in 0 until n) { val r1 = buildTransform { rotate(normals[i], alpha[i].asDegrees) } val r2 = buildTransform { rotate(normals[(i + 1).mod(normals.size)], -beta[i].asDegrees) }