summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-01-24 12:52:06 -0500
committerBen Gamari <ben@smart-cactus.org>2017-01-24 16:07:34 -0500
commit2cc67adb29b33e15727c6463ed84e43cc159b3a2 (patch)
tree2983243f63581c21b7c5440ceaf228413d9d088c
parentefc8e3b17bd374c5860081bd7350a1ce7c7cb92f (diff)
downloadhaskell-2cc67adb29b33e15727c6463ed84e43cc159b3a2.tar.gz
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: https://phabricator.haskell.org/D2967
-rw-r--r--compiler/main/HscTypes.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs
index 8e6925fe11..51cec26006 100644
--- a/compiler/main/HscTypes.hs
+++ b/compiler/main/HscTypes.hs
@@ -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
where
- 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)
where
- 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