on master help sign in
A tiny simplification
98b398bBryan O'Sullivan
Data/Aeson/Parser.hs+5−6
@@ -79,6 +79,8 @@ value = most <|> (Number <$> number)
79doubleQuote, backslash :: Word8
79doubleQuote, backslash :: Word8
80doubleQuote = 34
80doubleQuote = 34
81backslash = 92
81backslash = 92
82+{-# INLINE backslash #-}
83+{-# INLINE doubleQuote #-}
82
84
83jstring :: Parser Text
85jstring :: Parser Text
84jstring = A.word8 doubleQuote *> jstring_
86jstring = A.word8 doubleQuote *> jstring_
@@ -92,15 +94,12 @@ jstring_ = {-# SCC "jstring_" #-} do
92 else Just (c == backslash)
94 else Just (c == backslash)
93 _ <- A.word8 doubleQuote
95 _ <- A.word8 doubleQuote
94 if backslash `B.elem` s
96 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
96 else return (decodeUtf8 s)
100 else return (decodeUtf8 s)
97{-# INLINE jstring_ #-}
101{-# INLINE jstring_ #-}
98
102
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−
104unescape :: Z.Parser ByteString
103unescape :: Z.Parser ByteString
105unescape = toByteString <$> go mempty where
104unescape = toByteString <$> go mempty where
106 go acc = do
105 go acc = do