[commit: haddock] ghc-7.8: Get rid of re-implementation of sortBy (f6280ae)

git at git.haskell.org git at git.haskell.org
Mon Feb 17 14:09:41 UTC 2014


Repository : ssh://git@git.haskell.org/haddock

On branch  : ghc-7.8
Link       : http://git.haskell.org/haddock.git/commitdiff/f6280aec5d28bc49d5d6badc162d83745faf3f7e

>---------------------------------------------------------------

commit f6280aec5d28bc49d5d6badc162d83745faf3f7e
Author: Niklas Haas <git at nand.wakku.to>
Date:   Thu Feb 13 22:21:36 2014 +0100

    Get rid of re-implementation of sortBy
    
    I have no idea what this was doing lying around here, and due to the
    usage of tuples it's actually slower, too.
    
    Signed-off-by: Mateusz Kowalczyk <fuuzetsu at fuuzetsu.co.uk>
    
    (cherry picked from commit d86f68860c40d45d2cec94edd15d4bf4fc4292d8)


>---------------------------------------------------------------

f6280aec5d28bc49d5d6badc162d83745faf3f7e
 src/Haddock/Interface/AttachInstances.hs |   10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/Haddock/Interface/AttachInstances.hs b/src/Haddock/Interface/AttachInstances.hs
index a56759a..8c9d45c 100644
--- a/src/Haddock/Interface/AttachInstances.hs
+++ b/src/Haddock/Interface/AttachInstances.hs
@@ -19,6 +19,7 @@ import Haddock.Convert
 
 import Control.Arrow
 import Data.List
+import Data.Ord (comparing)
 import qualified Data.Map as Map
 import qualified Data.Set as Set
 
@@ -67,12 +68,12 @@ attachToExportItem expInfo iface ifaceMap instIfaceMap export =
                 case mb_info of
                   Just (_, _, cls_instances, fam_instances) ->
                     let fam_insts = [ (synifyFamInst i, n)
-                                    | i <- sortImage instFam fam_instances
+                                    | i <- sortBy (comparing instFam) fam_instances
                                     , let n = lookupInstDoc (getName i) iface ifaceMap instIfaceMap
                                     ]
                         cls_insts = [ (synifyInstHead i, lookupInstDoc n iface ifaceMap instIfaceMap)
                                     | let is = [ (instanceHead' i, getName i) | i <- cls_instances ]
-                                    , (i@(_,_,cls,tys), n) <- sortImage (first instHead) is
+                                    , (i@(_,_,cls,tys), n) <- sortBy (comparing $ first instHead) is
                                     , not $ isInstanceHidden expInfo cls tys
                                     ]
                     in cls_insts ++ fam_insts
@@ -163,11 +164,6 @@ instFam :: FamInst -> ([Int], Name, [SimpleType], Int, SimpleType)
 instFam FamInst { fi_fam = n, fi_tys = ts, fi_rhs = t }
   = (map argCount ts, n, map simplify ts, argCount t, simplify t)
 
--- sortImage f = sortBy (\x y -> compare (f x) (f y))
-sortImage :: Ord b => (a -> b) -> [a] -> [a]
-sortImage f xs = map snd $ sortBy cmp_fst [(f x, x) | x <- xs]
- where cmp_fst (x,_) (y,_) = compare x y
-
 
 funTyConName :: Name
 funTyConName = mkWiredInName gHC_PRIM



More information about the ghc-commits mailing list