cmm/: Avoid using lazy left folds
ClosedPublic

Authored by michalt on Mar 3 2018, 10:22 AM.

Details

Summary

This basically replaces all uses of foldl with foldl'. I've looked
at all the call sites and there doesn't seem to be any reason to prefer
the lazy version.

Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com>

Test Plan

./validate

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.
michalt created this revision.Mar 3 2018, 10:22 AM
bgamari accepted this revision.Mar 3 2018, 10:38 AM

Looks good to me.

One suggestion inline.

compiler/cmm/CmmBuildInfoTables.hs
281

This might be more clearly written as

cafset = Set.unions cafsets `Set.difference` Set.fromList lbls

I suspect this will be slightly faster too as we will avoid allocating an intermediate set for each deletion.

This revision is now accepted and ready to land.Mar 3 2018, 10:38 AM
michalt updated this revision to Diff 15633.Mar 3 2018, 2:15 PM
  • Change suggested by bgamari
michalt marked an inline comment as done.Mar 3 2018, 2:16 PM
michalt added inline comments.
compiler/cmm/CmmBuildInfoTables.hs
281

Nice! :)

michalt marked 2 inline comments as done.Mar 3 2018, 2:17 PM
This revision was automatically updated to reflect the committed changes.