From c19211774f509f2b0334073b599295538871a00f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 11 Dec 2019 14:12:22 -0400 Subject: use filepath-bytestring for annex object manipulations git-annex find is now RawFilePath end to end, no string conversions. So is git-annex get when it does not need to get anything. So this is a major milestone on optimisation. Benchmarks indicate around 30% speedup in both commands. Probably many other performance improvements. All or nearly all places where a file is statted use RawFilePath now. --- Logs.hs | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'Logs.hs') diff --git a/Logs.hs b/Logs.hs index d612aa8d56..18a045b452 100644 --- a/Logs.hs +++ b/Logs.hs @@ -13,6 +13,7 @@ import Annex.Common import Annex.DirHashes import qualified Data.ByteString as S +import qualified System.FilePath.ByteString as P {- There are several varieties of log file formats. -} data LogVariety @@ -117,19 +118,19 @@ exportLog = "export.log" {- The pathname of the location log file for a given key. -} locationLogFile :: GitConfig -> Key -> RawFilePath -locationLogFile config key = toRawFilePath $ - branchHashDir config key keyFile key ++ ".log" +locationLogFile config key = + branchHashDir config key P. keyFile' key <> ".log" {- The filename of the url log for a given key. -} urlLogFile :: GitConfig -> Key -> RawFilePath -urlLogFile config key = toRawFilePath $ - branchHashDir config key keyFile key ++ decodeBS' urlLogExt +urlLogFile config key = + branchHashDir config key P. keyFile' key <> urlLogExt {- Old versions stored the urls elsewhere. -} oldurlLogs :: GitConfig -> Key -> [RawFilePath] -oldurlLogs config key = map toRawFilePath - [ "remote/web" hdir serializeKey key ++ ".log" - , "remote/web" hdir keyFile key ++ ".log" +oldurlLogs config key = + [ "remote/web" P. hdir P. serializeKey' key <> ".log" + , "remote/web" P. hdir P. keyFile' key <> ".log" ] where hdir = branchHashDir config key @@ -144,7 +145,7 @@ isUrlLog file = urlLogExt `S.isSuffixOf` file {- The filename of the remote state log for a given key. -} remoteStateLogFile :: GitConfig -> Key -> RawFilePath remoteStateLogFile config key = - toRawFilePath (branchHashDir config key keyFile key) + (branchHashDir config key P. keyFile' key) <> remoteStateLogExt remoteStateLogExt :: S.ByteString @@ -156,7 +157,7 @@ isRemoteStateLog path = remoteStateLogExt `S.isSuffixOf` path {- The filename of the chunk log for a given key. -} chunkLogFile :: GitConfig -> Key -> RawFilePath chunkLogFile config key = - toRawFilePath (branchHashDir config key keyFile key) + (branchHashDir config key P. keyFile' key) <> chunkLogExt chunkLogExt :: S.ByteString @@ -168,7 +169,7 @@ isChunkLog path = chunkLogExt `S.isSuffixOf` path {- The filename of the metadata log for a given key. -} metaDataLogFile :: GitConfig -> Key -> RawFilePath metaDataLogFile config key = - toRawFilePath (branchHashDir config key keyFile key) + (branchHashDir config key P. keyFile' key) <> metaDataLogExt metaDataLogExt :: S.ByteString @@ -180,7 +181,7 @@ isMetaDataLog path = metaDataLogExt `S.isSuffixOf` path {- The filename of the remote metadata log for a given key. -} remoteMetaDataLogFile :: GitConfig -> Key -> RawFilePath remoteMetaDataLogFile config key = - toRawFilePath (branchHashDir config key keyFile key) + (branchHashDir config key P. keyFile' key) <> remoteMetaDataLogExt remoteMetaDataLogExt :: S.ByteString @@ -192,7 +193,7 @@ isRemoteMetaDataLog path = remoteMetaDataLogExt `S.isSuffixOf` path {- The filename of the remote content identifier log for a given key. -} remoteContentIdentifierLogFile :: GitConfig -> Key -> RawFilePath remoteContentIdentifierLogFile config key = - toRawFilePath (branchHashDir config key keyFile key) + (branchHashDir config key P. keyFile' key) <> remoteContentIdentifierExt remoteContentIdentifierExt :: S.ByteString -- cgit v1.2.3