summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim Breitner <mail@joachim-breitner.de>2015-09-07 13:19:50 +0200
committerJoachim Breitner <mail@joachim-breitner.de>2015-09-07 13:22:22 +0200
commitdc671a1c06736b192e4a53f580e17356ffa7224e (patch)
treefad61a18cea379381055a960cf9fd62964dfe2bb
parent1abbacd606c7fbbb5a948cf9fa3817f5ed20c37a (diff)
downloadhaskell-dc671a1c06736b192e4a53f580e17356ffa7224e.tar.gz
SPECIALIZE strictMinimum for Int and Integer
This fixes a regression reported in #10788, where due to less inlining compared to earlier versions, we’d get worse code. With the SPECIALIZE, we get the good code, and moreover, the good code is in List.hs and _not_ inlined to the use site, so smaller code size and less compilation time.
-rw-r--r--libraries/base/GHC/List.hs4
1 files changed, 4 insertions, 0 deletions
diff --git a/libraries/base/GHC/List.hs b/libraries/base/GHC/List.hs
index ca3fb757e3..86ff868a08 100644
--- a/libraries/base/GHC/List.hs
+++ b/libraries/base/GHC/List.hs
@@ -415,6 +415,8 @@ maximum xs = foldl1 max xs
strictMaximum :: (Ord a) => [a] -> a
strictMaximum [] = errorEmptyList "maximum"
strictMaximum xs = foldl1' max xs
+{-# SPECIALIZE strictMaximum :: [Int] -> Int #-}
+{-# SPECIALIZE strictMaximum :: [Integer] -> Integer #-}
-- | 'minimum' returns the minimum value from a list,
-- which must be non-empty, finite, and of an ordered type.
@@ -433,6 +435,8 @@ minimum xs = foldl1 min xs
strictMinimum :: (Ord a) => [a] -> a
strictMinimum [] = errorEmptyList "minimum"
strictMinimum xs = foldl1' min xs
+{-# SPECIALIZE strictMinimum :: [Int] -> Int #-}
+{-# SPECIALIZE strictMinimum :: [Integer] -> Integer #-}
-- | 'iterate' @f x@ returns an infinite list of repeated applications