diff --git a/kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/map.kt b/kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/map.kt
index cb3c6c6116c..fbb96aaf50d 100644
--- a/kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/map.kt
+++ b/kotest-property/src/commonMain/kotlin/io/kotest/property/arbitrary/map.kt
@@ -47,20 +47,18 @@ internal fun Arb.trampoline(next: (Sample) -> Arb): Arb = whe
@Suppress("UNCHECKED_CAST")
internal class TrampolineArb private constructor(
private val first: Arb,
- commands: List<(Sample) -> Arb>
+ private val commands: List<(Sample) -> Arb>
) : Arb() {
constructor(first: Arb) : this(first, emptyList())
- private val commandList: MutableList<(Sample) -> Arb> = commands.toMutableList()
-
fun thunk(fn: (Sample) -> Arb): TrampolineArb =
TrampolineArb(
first,
- commandList.toList() + (fn as (Sample) -> Arb)
+ commands + (fn as (Sample) -> Arb)
) as TrampolineArb
override fun edgecase(rs: RandomSource): A? =
- commandList
+ commands
.fold(first as Arb) { currentArb, next ->
val currentEdge = currentArb.edgecase(rs) ?: currentArb.sample(rs).value
next(Sample(currentEdge))
@@ -68,7 +66,7 @@ internal class TrampolineArb private constructor(
.edgecase(rs) as A?
override fun sample(rs: RandomSource): Sample =
- commandList
+ commands
.fold(first as Arb) { currentArb, next ->
next(currentArb.sample(rs))
}