Skip to content

IntMap: improve sharing in difference via pointer equality - #1241

Draft
sjakobi wants to merge 1 commit into
haskell:masterfrom
sjakobi:intmap-difference-ptreq
Draft

IntMap: improve sharing in difference via pointer equality#1241
sjakobi wants to merge 1 commit into
haskell:masterfrom
sjakobi:intmap-difference-ptreq

Conversation

@sjakobi

@sjakobi sjakobi commented Aug 21, 2026

Copy link
Copy Markdown
Member

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:

  • run benchmarks
  • check perf implications of SpecConstr-workaround via lazy
  • tests for sharing?!
  • Improve Note to read less "LLM-y"

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
@sjakobi sjakobi changed the title IntMap: improve sharing in difference via pointer equality IntMap: improve sharing in difference via pointer equality Aug 21, 2026
@meooow25

Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants