[commit: ghc] master: ghc-pkg: don't sort packages unnecessarily (151c4b0)

git at git.haskell.org git at git.haskell.org
Mon Dec 7 13:07:30 UTC 2015


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/151c4b0b6caff2e1af764699c54302933c628861/ghc

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

commit 151c4b0b6caff2e1af764699c54302933c628861
Author: Thomas Miedema <thomasmiedema at gmail.com>
Date:   Mon Dec 7 13:22:03 2015 +0100

    ghc-pkg: don't sort packages unnecessarily
    
    The packages in the package database are already sorted alphabetically
    by this point (see db_stack_sorted).
    
    This is a better fix for #8245, commit 021b1f8.
    
    Test Plan: look at output of './inplace/bin/ghc-pkg list
    [--simple-output]'
    
    Reviewers: austin, bgamari, psibi
    
    Reviewed By: psibi
    
    Differential Revision: https://phabricator.haskell.org/D1579
    
    GHC Trac Issues: #8245


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

151c4b0b6caff2e1af764699c54302933c628861
 utils/ghc-pkg/Main.hs | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index b089e7b..2820f70 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -36,7 +36,6 @@ import qualified Control.Exception as Exception
 import Data.Maybe
 
 import Data.Char ( isSpace, toLower )
-import Data.Ord (comparing)
 #if __GLASGOW_HASKELL__ < 709
 import Control.Applicative (Applicative(..))
 #endif
@@ -1243,12 +1242,10 @@ listPackages verbosity my_flags mPackageName mModuleName = do
 
       show_normal PackageDB{ location = db_name, packages = pkg_confs } =
           do hPutStrLn stdout (db_name ++ ":")
-             if null pp_pkgs
+             if null pkg_confs
                  then hPutStrLn stdout "    (no packages)"
-                 else hPutStrLn stdout $ unlines (map ("    " ++) pp_pkgs)
+                 else hPutStrLn stdout $ unlines (map ("    " ++) (map pp_pkg pkg_confs))
            where
-                 -- Sort using instance Ord PackageId
-                 pp_pkgs = map pp_pkg . sortBy (comparing installedComponentId) $ pkg_confs
                  pp_pkg p
                    | installedComponentId p `elem` broken = printf "{%s}" doc
                    | exposed p = doc
@@ -1305,8 +1302,7 @@ simplePackageList :: [Flag] -> [InstalledPackageInfo] -> IO ()
 simplePackageList my_flags pkgs = do
    let showPkg = if FlagNamesOnly `elem` my_flags then display . pkgName
                                                   else display
-       -- Sort using instance Ord PackageId
-       strs = map showPkg $ sort $ map sourcePackageId pkgs
+       strs = map showPkg $ map sourcePackageId pkgs
    when (not (null pkgs)) $
       hPutStrLn stdout $ concat $ intersperse " " strs
 



More information about the ghc-commits mailing list