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 cid.Prefix #109

Merged
merged 1 commit into from
Jul 23, 2020
Merged

feat: optimize cid.Prefix #109

merged 1 commit into from
Jul 23, 2020

Conversation

Stebalien
Copy link
Member

We call this frequently and having to allocate here is really unfortunate.

We call this frequently and having to allocate here is really unfortunate.
mhtype, n, _ := uvarint(c.str[offset:])
offset += n
mhlen, _, _ := uvarint(c.str[offset:])

return Prefix{

Choose a reason for hiding this comment

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

could allocate this struct before the uvarint's above, and then read version / type / codec directly into the member fields

Copy link
Member

Choose a reason for hiding this comment

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

eh, it won't save us anything. Its all in registers at the end of the day

@Kubuxu
Copy link
Member

Kubuxu commented Jul 23, 2020

@Stebalien are we sure that varint in the c.str is well structured? Otherwise uvarint witll return negative n.

@Kubuxu
Copy link
Member

Kubuxu commented Jul 23, 2020

Ahh, doc is bad. uvarint doesn't return negative n anymore.

@whyrusleeping whyrusleeping merged commit 8b9ff39 into master Jul 23, 2020
@aschmahmann aschmahmann mentioned this pull request Sep 22, 2020
72 tasks
@mvdan mvdan deleted the feat/optimize-prefix branch July 1, 2021 16:12
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.

4 participants