Skip to content

Commit

Permalink
Don't check buffer exhaustion while filling ints (#1424)
Browse files Browse the repository at this point in the history
The array size is already derived from the buffer size.
  • Loading branch information
JakeWharton committed Feb 6, 2024
1 parent c1aaf58 commit 062048a
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions okio/src/commonMain/kotlin/okio/Options.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 062048a

Please sign in to comment.