-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Introduce set with custom equals and getHashCode #48169
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable thing to have, although I'm tempted to say it should be in src/server since it's used only there. Probably having it in a central place is more valuable though.
Do you have a sense of how often you expect entries in the set to share a hash? If best practice is for hashes to be unique whenever possible (and it may not be, I don’t know), I wonder if it would be better to let the underlying map values be |
@andrewbranch Generally speaking, I'd expect collisions to be pretty common in a hashset, but I have no particular objection to dynamically promoting values to arrays - this is just the simplest code that solved my problem. Any thoughts on @sandersn's suggestion of clearly separating this from |
Personally, I don’t think it’s much of an issue since |
Re-opening to see if that causes it to pick up the additional commits I pushed. |
I got tired of not having custom hash sets in JS so I made a naive one.
Not using linear search to de-dup rename locations cuts search for locations of
Type
from 1750 ms to 1450 ms.I plan to use this in a bunch of other places in my FAR cleanup.
TODO: this is the simplest possible implementation
TODO: these were the consumers that I'd encountered recently