small RawFilePath optimisation
authorJoey Hess <joeyh@joeyh.name>
Thu, 2 Mar 2023 14:53:12 +0000 (10:53 -0400)
committerJoey Hess <joeyh@joeyh.name>
Thu, 2 Mar 2023 14:53:12 +0000 (10:53 -0400)
P2P/Protocol.hs
Utility/SystemDirectory.hs

index 1c998ae70c99c3bd3380cc1f7e228961b9992b92..a75a6e6b1a27f100c7bb4758ef3444371f065cf9 100644 (file)
@@ -32,9 +32,10 @@ import Control.Monad
 import Control.Monad.Free
 import Control.Monad.Free.TH
 import Control.Monad.Catch
-import System.FilePath
 import System.Exit (ExitCode(..))
 import System.IO
+import qualified System.FilePath.ByteString as P
+import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as L
 import Data.Char
 import Control.Applicative
@@ -179,11 +180,11 @@ instance Proto.Serializable ProtoAssociatedFile where
                        | isSpace c = "%"
                        | otherwise = [c]
        
-       deserialize s = case fromRawFilePath $ fromInternalGitPath $ toRawFilePath $ deesc [] s of
-               [] -> Just $ ProtoAssociatedFile $ AssociatedFile Nothing
+       deserialize s = case fromInternalGitPath $ toRawFilePath $ deesc [] s of
                f
-                       | isRelative f -> Just $ ProtoAssociatedFile $ 
-                               AssociatedFile $ Just $ toRawFilePath f
+                       | B.null f -> Just $ ProtoAssociatedFile $ AssociatedFile Nothing
+                       | P.isRelative f -> Just $ ProtoAssociatedFile $ 
+                               AssociatedFile $ Just f
                        | otherwise -> Nothing
          where
                deesc b [] = reverse b
index b9040fe13f79e9e38b77d556b5468750600f665c..a7d60f931e58e5ba1adadb4b1a39208b2d213e35 100644 (file)
@@ -1,4 +1,4 @@
-{- System.Directory without its conflicting isSymbolicLink
+{- System.Directory without its conflicting isSymbolicLink and getFileSize.
  -
  - Copyright 2016 Joey Hess <id@joeyh.name>
  -