minor optimisation

avoid repeated scan of the same bytestring
This commit is contained in:
Joey Hess 2019-11-22 19:13:05 -04:00
parent 61af9d8f63
commit ddf6973d22
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38

View file

@ -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