Commit 2cc67adb authored by Ben Gamari's avatar Ben Gamari Committed by Ben Gamari
Browse files

HscTypes: Use foldl' instead of foldr

In this case we are building a map, for which `foldl'` is much better
suited. This has a small but consistent impact on compiler allocations,
        -1 s.d.                -----          -0.161%
        +1 s.d.                -----          -0.011%
        Average                -----          -0.086%

Test Plan: Validate

Reviewers: austin

Subscribers: thomie

Differential Revision:
parent efc8e3b1
......@@ -194,6 +194,7 @@ import GHC.Serialized ( Serialized )
import Foreign
import Control.Monad ( guard, liftM, when, ap )
import Data.Foldable ( foldl' )
import Data.IORef
import Data.Time
import Exception
......@@ -1124,10 +1125,10 @@ mkIfaceHashCache :: [(Fingerprint,IfaceDecl)]
mkIfaceHashCache pairs
= \occ -> lookupOccEnv env occ
env = foldr add_decl emptyOccEnv pairs
add_decl (v,d) env0 = foldr add env0 (ifaceDeclFingerprints v d)
env = foldl' add_decl emptyOccEnv pairs
add_decl env0 (v,d) = foldl' add env0 (ifaceDeclFingerprints v d)
add (occ,hash) env0 = extendOccEnv env0 occ (occ,hash)
add env0 (occ,hash) = extendOccEnv env0 occ (occ,hash)
emptyIfaceHashCache :: OccName -> Maybe (OccName, Fingerprint)
emptyIfaceHashCache _occ = Nothing
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment