minor optimisation
avoid repeated scan of the same bytestring
This commit is contained in:
parent
61af9d8f63
commit
ddf6973d22
1 changed files with 2 additions and 1 deletions
|
@ -563,7 +563,7 @@ keyFile = fromRawFilePath . keyFile'
|
|||
keyFile' :: Key -> RawFilePath
|
||||
keyFile' k =
|
||||
let b = serializeKey' k
|
||||
in if any (`S8.elem` b) ['&', '%', ':', '/']
|
||||
in if S8.any (`elem` ['&', '%', ':', '/']) b
|
||||
then S8.concatMap esc b
|
||||
else b
|
||||
where
|
||||
|
@ -573,6 +573,7 @@ keyFile' k =
|
|||
esc '/' = "%"
|
||||
esc c = S8.singleton c
|
||||
|
||||
|
||||
{- Reverses keyFile, converting a filename fragment (ie, the basename of
|
||||
- the symlink target) into a key. -}
|
||||
fileKey :: FilePath -> Maybe Key
|
||||
|
|
Loading…
Reference in a new issue