Skip to content

Commit b99a834

Browse files
committed
Cleanup jstring_ a bit
1 parent 51f3303 commit b99a834

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Data/Aeson/Parser/Internal.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,14 +331,11 @@ key = Key.fromText <$> jstring
331331
jstring_ :: Parser Text
332332
{-# INLINE jstring_ #-}
333333
jstring_ = do
334-
-- not sure whether >= or bit hackery is faster
335-
-- perfectly, we shouldn't care, it's compiler job.
336334
s <- A.takeWhile (\w -> w /= DOUBLE_QUOTE && w /= BACKSLASH && w >= 0x20 && w < 0x80)
337-
let txt = unsafeDecodeASCII s
338335
mw <- A.peekWord8
339336
case mw of
340337
Nothing -> fail "string without end"
341-
Just DOUBLE_QUOTE -> A.anyWord8 $> txt
338+
Just DOUBLE_QUOTE -> A.anyWord8 $> unsafeDecodeASCII s
342339
Just w | w < 0x20 -> fail "unescaped control character"
343340
_ -> jstringSlow s
344341

@@ -354,9 +351,8 @@ jstringSlow s' = do
354351
go a c
355352
| a = Just False
356353
| c == DOUBLE_QUOTE = Nothing
357-
| otherwise = let a' = c == backslash
354+
| otherwise = let a' = c == BACKSLASH
358355
in Just a'
359-
where backslash = BACKSLASH
360356

361357
decodeWith :: Parser Value -> (Value -> Result a) -> L.ByteString -> Maybe a
362358
decodeWith p to s =

0 commit comments

Comments
 (0)