From 062048a7a71b1ca09c8fc5681b2400aa25d8e0c8 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Tue, 6 Feb 2024 11:50:17 -0500 Subject: [PATCH] Don't check buffer exhaustion while filling ints (#1424) The array size is already derived from the buffer size. --- okio/src/commonMain/kotlin/okio/Options.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/okio/src/commonMain/kotlin/okio/Options.kt b/okio/src/commonMain/kotlin/okio/Options.kt index b94054a2b5..8e8b4c4a02 100644 --- a/okio/src/commonMain/kotlin/okio/Options.kt +++ b/okio/src/commonMain/kotlin/okio/Options.kt @@ -75,10 +75,8 @@ class Options private constructor( val trieBytes = Buffer() buildTrieRecursive(node = trieBytes, byteStrings = list, indexes = indexes) - val trie = IntArray(trieBytes.intCount.toInt()) - var i = 0 - while (!trieBytes.exhausted()) { - trie[i++] = trieBytes.readInt() + val trie = IntArray(trieBytes.intCount.toInt()) { + trieBytes.readInt() } return Options(byteStrings.copyOf() /* Defensive copy. */, trie)