diff options
author | Ömer Sinan Ağacan <omeragacan@gmail.com> | 2019-11-11 14:03:45 +0300 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-11-19 11:55:36 -0500 |
commit | cd40e12ad8072c6b881c6bb650e39e4d29c9718c (patch) | |
tree | 43738ae5ced55ffe29d9eba0d8da395e15faaa6b | |
parent | ec8a463d1ff948ba9b1b0fbb538f7d5a237bf44a (diff) | |
download | haskell-cd40e12ad8072c6b881c6bb650e39e4d29c9718c.tar.gz |
Packages.hs: use O(n*log(n)) ordNub instead of O(n*n) nub
As reported in #8173 in some environments package lists can get quite
long, so we use more efficient ordNub instead of nub on package lists.
-rw-r--r-- | compiler/main/Packages.hs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs index ca2e74dfcf..f5a8c964b3 100644 --- a/compiler/main/Packages.hs +++ b/compiler/main/Packages.hs @@ -1601,8 +1601,8 @@ mkPackageState dflags dbs preload0 = do -- (NB: since this is only relevant for base/rts it doesn't matter -- that thisUnitIdInsts_ is not wired yet) -- - preload3 = nub $ filter (/= thisPackage dflags) - $ (basicLinkedPackages ++ preload2) + preload3 = ordNub $ filter (/= thisPackage dflags) + $ (basicLinkedPackages ++ preload2) -- Close the preload packages with their dependencies dep_preload <- closeDeps dflags pkg_db (zip (map toInstalledUnitId preload3) (repeat Nothing)) @@ -1781,7 +1781,7 @@ getPackageIncludePath dflags pkgs = collectIncludeDirs `fmap` getPreloadPackagesAnd dflags pkgs collectIncludeDirs :: [PackageConfig] -> [FilePath] -collectIncludeDirs ps = nub (filter notNull (concatMap includeDirs ps)) +collectIncludeDirs ps = ordNub (filter notNull (concatMap includeDirs ps)) -- | Find all the library paths in these and the preload packages getPackageLibraryPath :: DynFlags -> [PreloadUnitId] -> IO [String] @@ -1789,7 +1789,7 @@ getPackageLibraryPath dflags pkgs = collectLibraryPaths dflags `fmap` getPreloadPackagesAnd dflags pkgs collectLibraryPaths :: DynFlags -> [PackageConfig] -> [FilePath] -collectLibraryPaths dflags = nub . filter notNull +collectLibraryPaths dflags = ordNub . filter notNull . concatMap (libraryDirsForWay dflags) -- | Find all the link options in these and the preload packages, @@ -1810,7 +1810,7 @@ collectArchives dflags pc = filterM doesFileExist [ searchPath </> ("lib" ++ lib ++ ".a") | searchPath <- searchPaths , lib <- libs ] - where searchPaths = nub . filter notNull . libraryDirsForWay dflags $ pc + where searchPaths = ordNub . filter notNull . libraryDirsForWay dflags $ pc libs = packageHsLibs dflags pc ++ extraLibraries pc getLibs :: DynFlags -> [PreloadUnitId] -> IO [(String,String)] @@ -1885,7 +1885,7 @@ getPackageExtraCcOpts dflags pkgs = do getPackageFrameworkPath :: DynFlags -> [PreloadUnitId] -> IO [String] getPackageFrameworkPath dflags pkgs = do ps <- getPreloadPackagesAnd dflags pkgs - return (nub (filter notNull (concatMap frameworkDirs ps))) + return (ordNub (filter notNull (concatMap frameworkDirs ps))) -- | Find all the package frameworks in these and the preload packages getPackageFrameworks :: DynFlags -> [PreloadUnitId] -> IO [String] |