decode_c converted to ByteString

This speeds up a few things, notably CmdLine.Seek using Git.Filename
which uses decode_c and this avoids a conversion to String and back,
and probably the ByteString implementation of decode_c is also faster
for simple cases at least than the string version.

encode_c cannot be converted to ByteString (or if it did, it would have
to convert right back to String in order to handle unicode).

Sponsored-by: Brock Spratlen on Patreon
This commit is contained in:
Joey Hess 2023-04-07 14:44:19 -04:00
parent f0b1034f8f
commit 371d4f8183
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 57 additions and 36 deletions

View file

@ -248,7 +248,7 @@ secretKeys cmd = catchDefaultIO M.empty makemap
-- If the userid contains a ":" or a few other special
-- characters, gpg will hex-escape it. Use decode_c to
-- undo.
extract ((keyid, decode_c userid):c) Nothing rest
extract ((keyid, decodeBS (decode_c (encodeBS userid))):c) Nothing rest
extract c (Just keyid) rest@(("sec":_):_) =
extract ((keyid, ""):c) Nothing rest
extract c (Just keyid) (_:rest) =