-
Notifications
You must be signed in to change notification settings - Fork 103
Speed up difference and differenceWith #520
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
base: master
Are you sure you want to change the base?
Conversation
| unsafeInsertNewLeaf h0 l0 m0 = runST (go h0 l0 0 m0) | ||
| where | ||
| go !_ !l !_ Empty = return l | ||
| go h l@(Leaf _ lx) s t@(Leaf hy ly) |
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.
I suspect it's not good to have to "case" on the HashMap like this. It might be better to supply the Leaf k x within as an extra argument to unsafeInsertNewLeaf.
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 would probably cause additional allocations though, because the L-Leaf is by default unboxed within the Leaf HashMap node.
| -- See https://github.com/haskell-unordered-containers/unordered-containers/issues/75#issuecomment-1128419337 | ||
| {-# INLINE two #-} | ||
|
|
||
| two' :: Shift -> Hash -> HashMap k v -> Hash -> HashMap k v -> ST s (HashMap k v) |
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.
We should rather change two to have this type.
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.
I've refactored two and introduced two' in #521.
| unsafeInsertNewLeaf :: Hash -> HashMap k v -> HashMap k v -> HashMap k v | ||
| unsafeInsertNewLeaf h0 l0 m0 = runST (go h0 l0 0 m0) | ||
| where | ||
| go !_ !l !_ Empty = return l |
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.
| go !_ !l !_ Empty = return l | |
| go !_h l !_s Empty = return l |
It would probably be better to request that the "caller" ensures that the leaf is in WHNF.
|
#535 contains an even faster version of |
Context: #364
TODO:
Strict.differenceWith