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

small cleanups and optimizations #79

Merged
merged 6 commits into from
Oct 16, 2018
Merged

small cleanups and optimizations #79

merged 6 commits into from
Oct 16, 2018

Conversation

Stebalien
Copy link
Member

@Stebalien Stebalien commented Oct 1, 2018

Also includes one large change: Bytes() no longer copies. IMO, copying was a terrible (ok, maybe not that bad) mistake and cost us significantly in terms of performance.

This now just says "don't modify this or else...". IMO, that's a perfectly reasonable requirement (especially in go land).

This is a huge performance hit. Really, we just need to tell users not to modify
the result.

Also, get rid of an unnecessary pointer indirection (no api change).
This is checked when the protocol is *registered*. There's no reason to test it
twice.
This will perform all the correct checks *except* that it won't bother actually
stringifying the multiaddr. It should be significantly faster.
This showed up when profile go-ipfs.
@ghost
Copy link

ghost commented Oct 12, 2018

Sounds good, but we should check all usages of Bytes() - this change makes sense, but it'll potentially have bad consequences downstream.

@Stebalien
Copy link
Member Author

I've now checked (as well as I can) and I can't find any cases where we mutate this. I'd also be quite surprised if there were.

@Stebalien Stebalien merged commit 42326a8 into master Oct 16, 2018
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.

2 participants