From 47bc85a3a03a7ab5546cb66e6f43a6dc1548f094 Mon Sep 17 00:00:00 2001 From: Jake Wharton Date: Tue, 6 Feb 2024 11:11:23 -0500 Subject: [PATCH] Don't check buffer exhaustion while filling ints 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 6c13021896..f47e08878d 100644 --- a/okio/src/commonMain/kotlin/okio/Options.kt +++ b/okio/src/commonMain/kotlin/okio/Options.kt @@ -71,10 +71,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)