-
Notifications
You must be signed in to change notification settings - Fork 103
Use tree-diffing for difference
#535
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
|
Wow, the |
|
So the failing assertion is this one, introduced in b73381e: unordered-containers/Data/HashMap/Internal/Array.hs Lines 221 to 228 in 59ddae5
I don't see an obvious technical reason why an array shouldn't be shrunk to length 0, apart from the fact that an array of length 0 is useless for storing elements. In the case of the new So I'll just change |
At least in the context of `Array.filter` this seems useful and valid.
|
I agree that assertion is bogus. |
This reverts commit 98303d7.
...with GHC < 9.4.
|
This branch: |
| ------------------------------------------------------------------------ | ||
| -- * Difference and intersection | ||
|
|
||
| -- | \(O(n \log m)\) Difference of two maps. Return elements of the first map |
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 think the complexity is still the same. For example, if we do something like difference a large_superset_of_a, we end up checking each leaf of a against the superset.
Context: #536
e5e5d78 to
8d388a1
Compare
| case (i, A.index ary 0, A.index ary 1) of | ||
| (0, _, l) | isLeafOrCollision l -> l | ||
| (1, l, _) | isLeafOrCollision l -> l | ||
| _ -> bIndexed |
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.
Isn't it always 0 or 1, making the third branch unreachable? I suspect this part can be cleaned up by using let l = ... instead of binding that in a case branch.
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.
The third branch will be used when l isn't a Leaf or Collision.
I have opened #528 to clean up this pattern, and I'll eventually return to that PR! :)
| | A.length v == 2 -> | ||
| if i == 0 | ||
| then Leaf h (A.index v 1) | ||
| else Leaf h (A.index v 0) |
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.
Can't we just do Leaf h (A.index v (1 - i))?
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 think we can. But that's what's #528 is about.
Context: #364
TODO:
deleterefactoring affect its performance?delete''->deleteSubTreedelete''.gofunction is removed and we recurse todelete''itself?