Skip to content

Extend performance group with container-construction hints#1694

Open
mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda:performance-containers
Open

Extend performance group with container-construction hints#1694
mgajda wants to merge 1 commit intondmitchell:masterfrom
mgajda:performance-containers

Conversation

@mgajda
Copy link
Copy Markdown

@mgajda mgajda commented Apr 20, 2026

Part of a set of independent PRs adding rules to the opt-in
performance group (disabled by default; enabled via
--with-group=performance or per-project config). Each PR in the set
creates its own performance group block; the blocks merge cleanly.

This one covers redundant container construction (identity rewrites).

Rules added

All fully-qualified so they fire only on the exact API users imported.

  • Data.{Map,IntMap,HashMap}.{Strict,Lazy}.union m empty (both orders) → m
  • Data.{Set,HashSet}.union s empty (both orders) → s
  • Data.{Map,IntMap,HashMap}.Lazy.map id mm
  • Data.{Set,HashSet}.map id ss

Adds fully-qualified rewrites for no-op container operations that are
semantically identical to their shorter form but cost an O(n) pass.
Every match uses fully-qualified module names so it only fires on the
specific API the user imported.

- Data.{Map,IntMap,HashMap}.{Strict,Lazy}.union with empty -> the map
- Data.{Set,HashSet}.union with empty -> the set
- Data.{Map,IntMap,HashMap}.Lazy.map id -> the map
- Data.{Set,HashSet}.map id -> the set

The Strict map-id rewrites are deliberately NOT added: removing the
call would change evaluation semantics for containers holding bottoms.

All rules live in the opt-in `performance` group (enabled: false).
Part of a set of independent PRs adding rule families to that group;
each PR creates its own `performance` group block which merges cleanly
with the others on the maintainer's end.
@mgajda mgajda force-pushed the performance-containers branch from 6b84ea7 to 438494d Compare April 20, 2026 21:36
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.

1 participant