IntMap: improve sharing in difference via pointer equality - #1241
Conversation
Replace the mergeWithKey-based difference with a direct implementation that uses ptrEq to return the original (sub)tree when a recursive call removes nothing, instead of allocating an equal copy. This mirrors the sharing behavior Data.Map.difference gets from its size check and what Data.Set does with ptrEq. Assisted-by: Claude Fable 5
difference via pointer equality
|
Thanks for being interested in this, but before you spend more time on it let me say right away that I don't intend to review or accept any LLM-generated code. Of course, I don't speak for other maintainers, and maybe there is a discussion to be had about it, but my position is clear. |
|
Thanks for the heads-up, @meooow25! :) I should have probably made this clearer in the description, but I didn't mean to request your review at this stage. I opened the draft mostly to signal "I am interested in this". So I've started looking into SpecConstr on the GHC side for now, but eventually I'd like to see some sharing optimizations for IntMap and IntSet land here, including |
Replace the mergeWithKey-based difference with a direct implementation that uses ptrEq to return the original (sub)tree when a recursive call removes nothing, instead of allocating an equal copy. This mirrors the sharing behavior Data.Map.difference gets from its size check and what Data.Set does with ptrEq.
Context: #835, #227
TODO:
lazy