double speed of keyFile
Optimising for the common case of nothing needing to be escaped, from 5.434 μs to 1.727 μs. In the uncommon case, it only runs around 70 ns slower.
This commit is contained in:
parent
901fba3173
commit
1b6319a2c8
1 changed files with 5 additions and 1 deletions
|
@ -514,7 +514,11 @@ keyFile :: Key -> FilePath
|
|||
keyFile = fromRawFilePath . keyFile'
|
||||
|
||||
keyFile' :: Key -> RawFilePath
|
||||
keyFile' = S8.concatMap esc . serializeKey'
|
||||
keyFile' k =
|
||||
let b = serializeKey' k
|
||||
in if any (`S8.elem` b) ['&', '%', ':', '/']
|
||||
then S8.concatMap esc b
|
||||
else b
|
||||
where
|
||||
esc '&' = "&a"
|
||||
esc '%' = "&s"
|
||||
|
|
Loading…
Add table
Reference in a new issue