-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add safe decodeASCII' #499
Conversation
|
And the extra allocation in #448 would get optimized away if you just check the suffix for emptiness. |
With #448 merged, I'll rebase this and see what's left -- perhaps nothing, or perhaps a convenience definition if it seems sensible. |
Yeah, I think a |
c09ef52
to
1e12669
Compare
Thanks to @Lysxia 's fantastic work on decoding there's not much here now: decodeASCII' :: ByteString -> Maybe Text
decodeASCII' bs =
let (prefix, suffix) = decodeASCIIPrefix bs in
if B.empty suffix then Just t else Nothing
{-# INLINE decodeASCII' #-} What do people think? It's perhaps more convenient, but gives less information than |
dabd688
to
271c130
Compare
271c130
to
39e1e25
Compare
pushed fix |
Useful function for serialization libs. Currently you have to do something like this, which is nasty and weird for something that isn't really inherently so.
I find the decoding setup to be a little messy and this makes no attempt to improve on that. I wouldn't mind assisting on that work too.