Check for singletons when creating Bag/OrdList from a list.
ClosedPublic

Authored by AndreasK on Jun 2 2018, 5:01 AM.

Details

Summary

This gives us One x instead of Many (x : []) reducing overhead.
For compiling spectral/simple with -O0 difference was ~ -0.05% allocations.

The only drawback is that something like toOL (x:panic "") will now panic.
But that seems like a reasonable tradeoff.

Test Plan

ci, looking at +RTS -s

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
AndreasK created this revision.Jun 2 2018, 5:01 AM
AndreasK added a subscriber: jmct.
AndreasK updated this revision to Diff 16639.Jun 2 2018, 5:44 AM
  • Check for singletons in listToBag as well.
AndreasK retitled this revision from In OrdList use One x when converting from singleton lists. to Check for singletons when creating Bag/OrdList from a list..Jun 2 2018, 5:52 AM
AndreasK edited the summary of this revision. (Show Details)
AndreasK edited the summary of this revision. (Show Details)
bgamari accepted this revision.Jun 2 2018, 10:40 AM

Yep, seems quite reasonable.

This revision is now accepted and ready to land.Jun 2 2018, 10:40 AM
This revision was automatically updated to reflect the committed changes.