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

make Key.t unboxed to save memory #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

c-cube
Copy link

@c-cube c-cube commented Feb 24, 2024

This should save 2 words per map entry.

This should save 2 words per map entry.
@dbuenzli
Copy link
Owner

dbuenzli commented Feb 24, 2024

Sorry don't have this in my head. Is that orthogonal to #2 or does it solve it in a different manner ?

@c-cube
Copy link
Author

c-cube commented Feb 25, 2024

I'm not exactly sure, I suspect it's orthogonal. I also have an implementation that stores more stuff in the key, I think. You can use as much code from there as you want.

This PR exists simply because I saw a simple fix to apply :-)

@dbuenzli
Copy link
Owner

I also have an implementation that stores more stuff in the key, I think

If you can afford (>= 4.08) you should use the technique here for your key UIDs, rather than a counter. Yes its Obj but its usage has been sanctioned by upstream when Type.Id was added to the stdlib

@c-cube
Copy link
Author

c-cube commented Feb 25, 2024 via email

@dbuenzli
Copy link
Owner

dbuenzli commented Feb 25, 2024

Does this mean you can only have one key per type?

No you have one type id per key. You can have many unequal type ids for the same type. See the docs here and the trivial sample hmap implementation that follows.

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