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

@ -26,8 +26,7 @@ decode b = case S.uncons b of
Nothing -> b
Just (i, l)
| l /= q -> b
| otherwise ->
encodeBS $ decode_c $ decodeBS i
| otherwise -> decode_c i
where
q :: Word8
q = fromIntegral (ord '"')