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

Arena::alloc_with_id #10

Merged
merged 4 commits into from
Jan 30, 2019
Merged

Arena::alloc_with_id #10

merged 4 commits into from
Jan 30, 2019

Conversation

fitzgen
Copy link
Owner

@fitzgen fitzgen commented Jan 30, 2019

@fitzgen fitzgen requested a review from matklad January 30, 2019 00:28
@alexcrichton
Copy link
Collaborator

Hm so one thing I ran into transitioning, I'm not sure how we'd implement insert_with_id around here.

@fitzgen
Copy link
Owner Author

fitzgen commented Jan 30, 2019

Hm so one thing I ran into transitioning, I'm not sure how we'd implement insert_with_id around here.

Right because we couldn't construct the value to check whether it is already in the set without potentially adding duplicates.

I can make Arena::next_id public again, and then this wouldn't be a breaking change either... sound good?

@matklad
Copy link
Collaborator

matklad commented Jan 30, 2019

How that API is actually used? It is a sort of self-fulfilling proficy: if you construct an entity with a fresh id, it wouldn’t be in the set. If this is expected behavior, perhaps that could could change it’s next_id to with_id as well?

@fitzgen
Copy link
Owner Author

fitzgen commented Jan 30, 2019

How that API is actually used?

It is used by things whose equality/hash don't depend on the Id, for when we would like to de-duplicate items with a set whose storage is ultimately backed by an arena.

For example, function type declartations (which are separated and de-duped from the functions themselves): https://github.com/rustwasm/walrus/blob/ce985f826c89d2cc8e56e0d00b0a47c83bbd83af/src/module/types.rs#L56

@alexcrichton
Copy link
Collaborator

Leaving next_id is fine by me yeah!

It is a tiny bit more flexible that `alloc_with_id`, and is useful in the .1%
case.
@fitzgen fitzgen merged commit 7fde5a6 into master Jan 30, 2019
@fitzgen fitzgen deleted the alloc-with-id branch January 30, 2019 22:19
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.

3 participants