You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This implementation is probably missing minor things, but it should do very decently for a first draft. Let me know if there are things that should be replaced or bettered.
This implements EcoMap and tests for everything EcoMap. EcoMap can be inline, or spilled, where it's a simple CoW Rc (or Arc in case of sync flag added) wrapper of a hashmap (std's or hashbrown's in a no_std environment). This state is determined by a const generic N with a sensible default that the user may or may not provide.
We also integrate serde and rayon's parallel iterators in the case of sync.
Thanks for taking a stab at this. However, I'm afraid that the design goal I would have in mind for EcoMap diverges quite a bit from this implementation. What this implementation does is:
Inline storage
Fall back to Arc<HashMap<..>> for heap storage (two allocations and double indirection)
What I would have in mind:
No inline storage
A single shared allocation for the reference count and the underlying data (and thus also no double indirection)
This would make EcoMap a direct parallel of EcoVec, since EcoVec doesn't have inline storage either. Of course, EcoString does have it, but it's a bit more special and not a generic collection container, so it's not the reference point I would take.
I'm not sure whether it's possible to do this with hashbrown, which is one of the reasons why I didn't even attempt to add this before. As, to keep performance parity with hashbrown, we might have to basically maintain a fork.
Another priority for me would be to have the code structured in a way that makes an EcoIndexVec feasible with as little duplication as possible (or maybe to even have insertion ordering by default if possible without excessive overhead) as that would be the most interesting collection in the context of Typst (to back the dictionary type).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This implementation is probably missing minor things, but it should do very decently for a first draft. Let me know if there are things that should be replaced or bettered.
This implements EcoMap and tests for everything EcoMap. EcoMap can be inline, or spilled, where it's a simple CoW Rc (or Arc in case of sync flag added) wrapper of a hashmap (std's or hashbrown's in a no_std environment). This state is determined by a const generic N with a sensible default that the user may or may not provide.
We also integrate serde and rayon's parallel iterators in the case of sync.