slight optimisation more
This commit is contained in:
parent
c1c976d1fa
commit
fc21cccf1c
2 changed files with 10 additions and 2 deletions
4
Key.hs
4
Key.hs
|
@ -93,7 +93,7 @@ buildKeyFile k = byteString (formatKeyVariety (keyVariety k))
|
||||||
_ ?: Nothing = mempty
|
_ ?: Nothing = mempty
|
||||||
|
|
||||||
key2file :: Key -> FilePath
|
key2file :: Key -> FilePath
|
||||||
key2file = decodeBL . key2file'
|
key2file = decodeBL' . key2file'
|
||||||
|
|
||||||
key2file' :: Key -> L.ByteString
|
key2file' :: Key -> L.ByteString
|
||||||
key2file' = toLazyByteStringWith (safeStrategy 128 smallChunkSize) L.empty . buildKeyFile
|
key2file' = toLazyByteStringWith (safeStrategy 128 smallChunkSize) L.empty . buildKeyFile
|
||||||
|
@ -136,7 +136,7 @@ keyFileParser = do
|
||||||
parsechunknum = parseopt $ A8.char 'C' *> A8.decimal
|
parsechunknum = parseopt $ A8.char 'C' *> A8.decimal
|
||||||
|
|
||||||
file2key :: FilePath -> Maybe Key
|
file2key :: FilePath -> Maybe Key
|
||||||
file2key = file2key' . encodeBS
|
file2key = file2key' . encodeBS'
|
||||||
|
|
||||||
file2key' :: S.ByteString -> Maybe Key
|
file2key' :: S.ByteString -> Maybe Key
|
||||||
file2key' b = eitherToMaybe $ A.parseOnly keyFileParser b
|
file2key' b = eitherToMaybe $ A.parseOnly keyFileParser b
|
||||||
|
|
|
@ -19,6 +19,8 @@ module Utility.FileSystemEncoding (
|
||||||
encodeBL,
|
encodeBL,
|
||||||
decodeBS,
|
decodeBS,
|
||||||
encodeBS,
|
encodeBS,
|
||||||
|
decodeBL',
|
||||||
|
encodeBL',
|
||||||
decodeBS',
|
decodeBS',
|
||||||
encodeBS',
|
encodeBS',
|
||||||
decodeW8,
|
decodeW8,
|
||||||
|
@ -151,6 +153,12 @@ decodeBS' = encodeW8 . S.unpack
|
||||||
encodeBS' :: FilePath -> S.ByteString
|
encodeBS' :: FilePath -> S.ByteString
|
||||||
encodeBS' = S.pack . decodeW8
|
encodeBS' = S.pack . decodeW8
|
||||||
|
|
||||||
|
decodeBL' :: L.ByteString -> FilePath
|
||||||
|
decodeBL' = encodeW8 . L.unpack
|
||||||
|
|
||||||
|
encodeBL' :: FilePath -> L.ByteString
|
||||||
|
encodeBL' = L.pack . decodeW8
|
||||||
|
|
||||||
{- Recent versions of the unix package have this alias; defined here
|
{- Recent versions of the unix package have this alias; defined here
|
||||||
- for backwards compatibility. -}
|
- for backwards compatibility. -}
|
||||||
type RawFilePath = S.ByteString
|
type RawFilePath = S.ByteString
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue