[commit: ghc] wip/nfs-locking: Experiment with a more efficient version of -/- in Settings.Paths (c50799d)

git at git.haskell.org git at git.haskell.org
Fri Oct 27 00:24:52 UTC 2017


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

On branch  : wip/nfs-locking
Link       : http://ghc.haskell.org/trac/ghc/changeset/c50799d46b53afbde517be8ca1626ef37a626d8f/ghc

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

commit c50799d46b53afbde517be8ca1626ef37a626d8f
Author: Andrey Mokhov <andrey.mokhov at gmail.com>
Date:   Thu Mar 10 12:34:51 2016 +0000

    Experiment with a more efficient version of -/- in Settings.Paths
    
    See #218.


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

c50799d46b53afbde517be8ca1626ef37a626d8f
 src/Settings/Paths.hs | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/Settings/Paths.hs b/src/Settings/Paths.hs
index 62a5c57..678ed92 100644
--- a/src/Settings/Paths.hs
+++ b/src/Settings/Paths.hs
@@ -11,20 +11,25 @@ import GHC
 import Oracles.PackageData
 import Settings.User
 
+-- A more efficient version of '-/-' which assumes that given FilePaths have
+-- already been unified. See #218. TODO: Switch to 'newtype FilePath'.
+(~/~) :: FilePath -> FilePath -> FilePath
+x ~/~ y = x ++ '/' : y
+
 -- | Path to the directory containing build artefacts of a given 'Context'.
 buildPath :: Context -> FilePath
 buildPath context at Context {..} =
-    buildRootPath -/- contextDirectory context -/- pkgPath package
+    buildRootPath ~/~ contextDirectory context ~/~ pkgPath package
 
 -- | Path to the @package-data.mk@ of a given 'Context'.
 pkgDataFile :: Context -> FilePath
-pkgDataFile context = buildPath context -/- "package-data.mk"
+pkgDataFile context = buildPath context ~/~ "package-data.mk"
 
 -- | Path to the haddock file of a given 'Context', e.g.:
 -- ".build/stage1/libraries/array/doc/html/array/array.haddock".
 pkgHaddockFile :: Context -> FilePath
 pkgHaddockFile context at Context {..} =
-    buildPath context -/- "doc/html" -/- name -/- name <.> "haddock"
+    buildPath context ~/~ "doc/html" ~/~ name ~/~ name <.> "haddock"
   where name = pkgNameString package
 
 -- | Path to the library file of a given 'Context', e.g.:
@@ -50,25 +55,25 @@ pkgFile :: Context -> String -> String -> Action FilePath
 pkgFile context prefix suffix = do
     let path = buildPath context
     componentId <- pkgData $ ComponentId path
-    return $ path -/- prefix ++ componentId ++ suffix
+    return $ path ~/~ prefix ++ componentId ++ suffix
 
 -- | Build directory for in-tree GMP library.
 gmpBuildPath :: FilePath
-gmpBuildPath = buildRootPath -/- "stage1/gmp"
+gmpBuildPath = buildRootPath ~/~ "stage1/gmp"
 
 -- | Path to the GMP library buildinfo file.
 gmpBuildInfoPath :: FilePath
-gmpBuildInfoPath = pkgPath integerGmp -/- "integer-gmp.buildinfo"
+gmpBuildInfoPath = pkgPath integerGmp ~/~ "integer-gmp.buildinfo"
 
 -- TODO: move to buildRootPath, see #113
 -- StageN, N > 0, share the same packageDbDirectory
 -- | Path to package database directory of a given 'Stage'.
 packageDbDirectory :: Stage -> FilePath
-packageDbDirectory Stage0 = buildRootPath -/- "stage0/bootstrapping.conf"
+packageDbDirectory Stage0 = buildRootPath ~/~ "stage0/bootstrapping.conf"
 packageDbDirectory _      = "inplace/lib/package.conf.d"
 
 -- | Path to the configuration file of a given 'Context'.
 pkgConfFile :: Context -> Action FilePath
 pkgConfFile context at Context {..} = do
     componentId <- pkgData . ComponentId $ buildPath context
-    return $ packageDbDirectory stage -/- componentId <.> "conf"
+    return $ packageDbDirectory stage ~/~ componentId <.> "conf"



More information about the ghc-commits mailing list