Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't check buffer exhaustion while filling ints #1424

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

JakeWharton
Copy link
Member

The array size is already derived from the buffer size.

The array size is already derived from the buffer size.
while (!trieBytes.exhausted()) {
trie[i++] = trieBytes.readInt()
val trie = IntArray(trieBytes.intCount.toInt()) {
trieBytes.readInt()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you still need to loop over it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a loop. It's called once for each position in the array.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooooh I misread that the previouew code wasn't doing that in the block passed to IntArray.

while (!trieBytes.exhausted()) {
trie[i++] = trieBytes.readInt()
val trie = IntArray(trieBytes.intCount.toInt()) {
trieBytes.readInt()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooooh I misread that the previouew code wasn't doing that in the block passed to IntArray.

@swankjesse swankjesse merged commit 062048a into master Feb 6, 2024
11 checks passed
@swankjesse swankjesse deleted the jw.one-more.2024-02-06 branch February 6, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants