optimisation

Avoid unnecessary conversion to/from String.
This commit is contained in:
Joey Hess 2021-04-20 13:13:45 -04:00
parent c30557594e
commit b2222e4639
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
2 changed files with 5 additions and 3 deletions

View file

@ -411,7 +411,7 @@ files = do
-- so use getJournalledFilesStale which should be much smaller most -- so use getJournalledFilesStale which should be much smaller most
-- of the time. branchFiles will stream as the list is consumed. -- of the time. branchFiles will stream as the list is consumed.
l <- (++) l <- (++)
<$> (map toRawFilePath <$> getJournalledFilesStale) <$> getJournalledFilesStale
<*> pure bfs <*> pure bfs
return (l, cleanup) return (l, cleanup)

View file

@ -9,6 +9,8 @@
- Licensed under the GNU AGPL version 3 or higher. - Licensed under the GNU AGPL version 3 or higher.
-} -}
{-# LANGUAGE OverloadedStrings #-}
module Annex.Journal where module Annex.Journal where
import Annex.Common import Annex.Common
@ -78,13 +80,13 @@ getJournalFileStale file = inRepo $ \g -> catchMaybeIO $
{- List of existing journal files, but without locking, may miss new ones {- List of existing journal files, but without locking, may miss new ones
- just being added, or may have false positives if the journal is staged - just being added, or may have false positives if the journal is staged
- as it is run. -} - as it is run. -}
getJournalledFilesStale :: Annex [FilePath] getJournalledFilesStale :: Annex [RawFilePath]
getJournalledFilesStale = do getJournalledFilesStale = do
g <- gitRepo g <- gitRepo
fs <- liftIO $ catchDefaultIO [] $ fs <- liftIO $ catchDefaultIO [] $
getDirectoryContents $ fromRawFilePath $ gitAnnexJournalDir g getDirectoryContents $ fromRawFilePath $ gitAnnexJournalDir g
return $ filter (`notElem` [".", ".."]) $ return $ filter (`notElem` [".", ".."]) $
map (fromRawFilePath . fileJournal . toRawFilePath) fs map (fileJournal . toRawFilePath) fs
withJournalHandle :: (DirectoryHandle -> IO a) -> Annex a withJournalHandle :: (DirectoryHandle -> IO a) -> Annex a
withJournalHandle a = do withJournalHandle a = do