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

feat: optimize decoding #15

Merged
merged 1 commit into from
Nov 23, 2022
Merged

feat: optimize decoding #15

merged 1 commit into from
Nov 23, 2022

Conversation

Stebalien
Copy link
Member

This speeds up decoding by about 20%. Suggested by @jwinkler2083233 in

Fixes #14.

@Stebalien Stebalien requested a review from Kubuxu March 20, 2022 20:23
This speeds up decoding by about 20%. Suggested by @jwinkler2083233 in

Fixes #14.
// "eof" will look like a success.
// If we've read part of a value, this is not a
// success.
err = io.ErrUnexpectedEOF
}
return 0, err
}
if (i == 8 && b >= 0x80) || i >= MaxLenUvarint63 {
if (s == 56 && b >= 0x80) || s >= (7*MaxLenUvarint63) {

Choose a reason for hiding this comment

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

this is the only use of MaxLenUvarint63 - should we have the constant be 63, rather than a 7 here and 9 as the constant?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a public constant and useful for checking buffer sizes.

Copy link
Member Author

Choose a reason for hiding this comment

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

(also used by go-msgio, which we really need to kill)

@Stebalien Stebalien merged commit df67645 into master Nov 23, 2022
@Stebalien
Copy link
Member Author

Thanks for the review!

@Stebalien Stebalien deleted the feat/optimize-decode branch November 23, 2022 00:19
Copy link
Member

@Kubuxu Kubuxu left a comment

Choose a reason for hiding this comment

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

LGTM, sorry, I missed the review request somehow

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.

performance improvement for ReadUvarint()
3 participants