optimise literalOsPath
Taking a ShortByteString and using OverloadedStrings should avoid it being converted from a String. The reason there is no IsString instance for OsPath is presumably the bad behavior of IsString for ByteString on unicode btw. But literalOsPath won't be used with unicode in git-annex. Sponsored-by: unqueued
This commit is contained in:
parent
8bafe05500
commit
98a0a9ddff
10 changed files with 23 additions and 7 deletions
|
@ -46,10 +46,6 @@ instance OsPathConv FilePath where
|
|||
toOsPath = toOsPath . toRawFilePath
|
||||
fromOsPath = fromRawFilePath . fromOsPath
|
||||
|
||||
{- Used for string constants. -}
|
||||
literalOsPath :: String -> OsPath
|
||||
literalOsPath = toOsPath
|
||||
|
||||
#ifdef WITH_OSPATH
|
||||
instance OsPathConv RawFilePath where
|
||||
toOsPath = bytesToOsPath . S.toShort
|
||||
|
@ -80,6 +76,10 @@ bytesFromOsPath = getPosixString . getOsString
|
|||
getSearchPath :: IO [OsPath]
|
||||
getSearchPath = map toOsPath <$> PB.getSearchPath
|
||||
|
||||
{- Used for string constants. -}
|
||||
literalOsPath :: ShortByteString -> OsPath
|
||||
literalOsPath = bytesToOsPath
|
||||
|
||||
#else
|
||||
{- When not building with WITH_OSPATH, use RawFilePath.
|
||||
-}
|
||||
|
@ -97,4 +97,7 @@ instance OsPathConv ShortByteString where
|
|||
|
||||
unsafeFromChar :: Char -> Word8
|
||||
unsafeFromChar = fromIntegral . ord
|
||||
|
||||
literalOsPath :: RawFilePath -> OsPath
|
||||
literalOsPath = id
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue