wip RawFilePath

Goal is to make git-annex faster by using ByteString for all the
worktree traversal. For now, this is focusing on Command.Find,
in order to benchmark how much it helps. (All other commands are
temporarily disabled)

Currently in a very bad unbuildable in-between state.
This commit is contained in:
Joey Hess 2019-11-25 16:18:19 -04:00
parent 1f035c0d66
commit 6a97ff6b3a
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
25 changed files with 258 additions and 200 deletions

View file

@ -17,38 +17,39 @@ module Types.Export (
import Git.FilePath
import Utility.Split
import Utility.FileSystemEncoding
import qualified System.FilePath.Posix as Posix
-- A location on a remote that a key can be exported to.
-- The FilePath will be relative to the top of the remote,
-- The RawFilePath will be relative to the top of the remote,
-- and uses unix-style path separators.
newtype ExportLocation = ExportLocation FilePath
newtype ExportLocation = ExportLocation RawFilePath
deriving (Show, Eq)
mkExportLocation :: FilePath -> ExportLocation
mkExportLocation :: RawFilePath -> ExportLocation
mkExportLocation = ExportLocation . toInternalGitPath
fromExportLocation :: ExportLocation -> FilePath
fromExportLocation :: ExportLocation -> RawFilePath
fromExportLocation (ExportLocation f) = f
newtype ExportDirectory = ExportDirectory FilePath
newtype ExportDirectory = ExportDirectory RawFilePath
deriving (Show, Eq)
mkExportDirectory :: FilePath -> ExportDirectory
mkExportDirectory :: RawFilePath -> ExportDirectory
mkExportDirectory = ExportDirectory . toInternalGitPath
fromExportDirectory :: ExportDirectory -> FilePath
fromExportDirectory :: ExportDirectory -> RawFilePath
fromExportDirectory (ExportDirectory f) = f
-- | All subdirectories down to the ExportLocation, with the deepest ones
-- last. Does not include the top of the export.
exportDirectories :: ExportLocation -> [ExportDirectory]
exportDirectories (ExportLocation f) =
map (ExportDirectory . Posix.joinPath . reverse) (subs [] dirs)
map (ExportDirectory . encodeBS . Posix.joinPath . reverse) (subs [] dirs)
where
subs _ [] = []
subs ps (d:ds) = (d:ps) : subs (d:ps) ds
dirs = map Posix.dropTrailingPathSeparator $
dropFromEnd 1 $ Posix.splitPath f
dropFromEnd 1 $ Posix.splitPath $ decodeBS f

View file

@ -19,10 +19,10 @@ import Utility.FileSystemEncoding
- location on the remote. -}
type ImportLocation = ExportLocation
mkImportLocation :: FilePath -> ImportLocation
mkImportLocation :: RawFilePath -> ImportLocation
mkImportLocation = mkExportLocation
fromImportLocation :: ImportLocation -> FilePath
fromImportLocation :: ImportLocation -> RawFilePath
fromImportLocation = fromExportLocation
{- An identifier for content stored on a remote that has been imported into