on master help sign in
A tiny simplification
commit98b398b717216408e780d59023b16b884db1875c authorBryan O'Sullivan <bos@mailrank.com> dateSun 20 Mar 2011, 16:14 (16 years ago) parentd044e17
1 file changed+5−6
Data/Aeson/Parser.hs+5−6
Data/Aeson/Parser.hs+5−6
@@ -79,6 +79,8 @@ value = most <|> (Number <$> number)
7979doubleQuote, backslash :: Word8
8080doubleQuote = 34
8181backslash = 92
82+{-# INLINE backslash #-}
83+{-# INLINE doubleQuote #-}
8284
8385jstring :: Parser Text
8486jstring = A.word8 doubleQuote *> jstring_
@@ -92,15 +94,12 @@ jstring_ = {-# SCC "jstring_" #-} do
9294 else Just (c == backslash)
9395 _ <- A.word8 doubleQuote
9496 if backslash `B.elem` s
95− then decodeUtf8 <$> reparse unescape s
97+ then case Z.parse unescape s of
98+ Right r -> return (decodeUtf8 r)
99+ Left err -> fail err
96100 else return (decodeUtf8 s)
97101{-# INLINE jstring_ #-}
98102
99−reparse :: Z.Parser a -> ByteString -> Parser a
100−reparse p s = case Z.parse p s of
101− Right r -> return r
102− Left err -> fail err
103−
104103unescape :: Z.Parser ByteString
105104unescape = toByteString <$> go mempty where
106105 go acc = do