-
Notifications
You must be signed in to change notification settings - Fork 183
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
Add more BTreeMap like apis to LiteMap #6068
base: main
Are you sure you want to change the base?
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.
Thanks, I've been missing these! A couple small comments
I'm all in favor of I've pushed back for a long time on a generic
We have |
I agree around |
If someone wants to use If we did add |
I agree that extend is tricky, but I was hoping that we could add a sort + dedup-based version to curb the worst case while allowing good drop-in experience.
Let's add that, sounds good.
I'm afraid I could be missing something obvious, but I don't think there is a sort step right now and it's N² worst case. |
I see, I thought FromIterator was icu4x/utils/litemap/src/store/vec_impl.rs Line 110 in eaaf49f
|
I fixed the quadratic behavior and implemented
Before After |
Once this PR is sorted, I'll open another PR to improve the serde deserialization and avoid quadratic worst case whenever possible. As it stands it's a potential attack vector. |
Add BTreeMap-like APIs to LiteMap to get closer to the std lib BTreeMap, which has familiarity benefits and allows easier integration of LiteMap into existing projects. This is a follow up of #5894
Extend
is based oninsert
, which can degrade to quadratic in theory. But it should be fine for the map sizes recommended forLiteMap
.FromIterator
implementation. It's maybe worth looking into a sort() + dedup() kind of implementation if it falls out of the fast-pathtry_get_or_insert
exists, the Entry API is a more familiar API with good performance, as it may avoid a potentially wasted second binary search.