-
Notifications
You must be signed in to change notification settings - Fork 4
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
Is it possible to reduce allocations when interning a byte slice? #18
Comments
Not with this package, no. If you don't care about growing your map forever you can use a map, as you show. This package cares about letting the GC still do its job and reclaim things. |
We would like to avoid growing the map indefinitely, but we would also like to avoid the allocation caused by converting the I had hoped that we could just add |
https://github.com/josharian/intern might (might!) be a better fit for you |
These are hard to automatically satisfy at the same time. See also the discussion at https://commaok.xyz/post/intern-strings/ |
Thanks for the link to the library and the article! Looking at the implementation of Perhaps something like golang/go#43615 or other changes to the runtime will make all of this more convenient in the future. |
Hi, thank you for creating an awesome interning package!
Could you please advice whether it's possible to reduce allocations when interning a byte slice (a buffer that changes on every iteration and might contain duplicate strings)?
For example, when interning is implemented using
map[string]string
, it would allocate only if a string wasn't found.The text was updated successfully, but these errors were encountered: