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

Purpose of Arc in Multiaddr #90

Open
dariusc93 opened this issue Apr 27, 2023 · 2 comments
Open

Purpose of Arc in Multiaddr #90

dariusc93 opened this issue Apr 27, 2023 · 2 comments

Comments

@dariusc93
Copy link

i was searching for why Arc was used after my overnight test shown additional allocation tracing back to the Arc in Multiaddr (probably unrelated, though it did catch my eye). The previous commit that made the change did not mention the reason for using it, and looking over the code, removing the Arc should work just fine and without being a breaking change.

@thomaseizinger
Copy link
Contributor

I believe the idea is that it is cheap to clone. The Multiaddr::push function for example uses clone-on-write to either reuse the current allocation if there are no other copies or make a new one on the fly.

@imbrem
Copy link

imbrem commented Apr 28, 2023

I've made pull request #89 to preserve the cheap clone while making the semantics clearer and improving (hopefully, still benchmarking) efficiency by using an EcoVec<u8>, downside is it adds a dependency on https://github.com/typst/ecow

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

No branches or pull requests

3 participants