Skip to content

Commit

Permalink
Reduce intermediate allocations when create Options
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton committed Feb 5, 2024
1 parent 8b54035 commit a88cd34
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion okio/src/commonMain/kotlin/okio/Options.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a88cd34

Please sign in to comment.