From a88cd34f13d02fc2b648fd23c944042a33c3256c Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Mon, 5 Feb 2024 09:57:08 -0500 Subject: [PATCH] Reduce intermediate allocations when create Options --- okio/src/commonMain/kotlin/okio/Options.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/okio/src/commonMain/kotlin/okio/Options.kt b/okio/src/commonMain/kotlin/okio/Options.kt index e8dae6e12f..6c13021896 100644 --- a/okio/src/commonMain/kotlin/okio/Options.kt +++ b/okio/src/commonMain/kotlin/okio/Options.kt @@ -40,7 +40,7 @@ class Options private constructor( // indexes to the caller's indexes. val list = byteStrings.toMutableList() list.sort() - val indexes = mutableListOf(*byteStrings.map { -1 }.toTypedArray()) + val indexes = MutableList(list.size) { -1 } byteStrings.forEachIndexed { callerIndex, byteString -> val sortedIndex = list.binarySearch(byteString) indexes[sortedIndex] = callerIndex