@@ -2,9 +2,6 @@
22{-# LANGUAGE CPP #-}
33{-# LANGUAGE NoImplicitPrelude #-}
44{-# LANGUAGE OverloadedStrings #-}
5−#if MIN_VERSION_ghc_prim(0,3,1)
6−{-# LANGUAGE MagicHash #-}
7−#endif
85#if __GLASGOW_HASKELL__ <= 710 && __GLASGOW_HASKELL__ >= 706
96-- Work around a compiler bug
107{-# OPTIONS_GHC -fsimpl-tick-factor=200 #-}
@@ -61,6 +58,7 @@ import Data.Functor.Compat (($>))
6158import Data.Bits (testBit)
6259import Data.Scientific (Scientific)
6360import Data.Text (Text)
61+import qualified Data.Text.Encoding as TE
6462import Data.Vector (Vector)
6563import qualified Data.Vector as Vector (empty, fromList, fromListN, reverse)
6664import qualified Data.Attoparsec.ByteString as A
@@ -72,12 +70,6 @@ import qualified Data.HashMap.Strict as H
7270import qualified Data.Scientific as Sci
7371import Data.Aeson.Parser.Unescape (unescapeText)
7472
75−#if MIN_VERSION_ghc_prim(0,3,1)
76−import GHC.Base (Int#, (==#), isTrue#, word2Int#, orI#, andI#)
77−import GHC.Word (Word8(W8#))
78−import qualified Data.Text.Encoding as TE
79−#endif
80−
8173#define BACKSLASH 92
8274#define CLOSE_CURLY 125
8375#define CLOSE_SQUARE 93
@@ -336,34 +328,6 @@ jstring_ = do
336328jstringSlow :: B.ByteString -> Parser Text
337329{-# INLINE jstringSlow #-}
338330jstringSlow s' = {-# SCC "jstringSlow" #-} do
339−#if MIN_VERSION_ghc_prim(0,3,1)
340− (s, S _ escaped) <- A.runScanner startState go <* A.anyWord8
341− -- We escape only if there are
342− -- non-ascii (over 7bit) characters or backslash present.
343− --
344− -- Note: if/when text will have fast ascii -> text conversion
345− -- (e.g. uses utf8 encoding) we can have further speedup.
346− if isTrue# escaped
347− then case unescapeText (s' <> s) of
348− Right r -> return r
349− Left err -> fail $ show err
350− else return (TE.decodeUtf8 (s' <> s))
351− where
352− startState = S 0# 0#
353− go (S skip escaped) (W8# c)
354− | isTrue# skip = Just (S 0# escaped')
355− | isTrue# (w ==# 34#) = Nothing -- double quote
356− | otherwise = Just (S skip' escaped')
357− where
358− w = word2Int# c
359− skip' = w ==# 92# -- backslash
360− escaped' = escaped
361− `orI#` (w `andI#` 0x80# ==# 0x80#) -- c >= 0x80
362− `orI#` skip'
363− `orI#` (w `andI#` 0x1f# ==# w) -- c < 0x20
364−
365−data S = S Int# Int#
366−#else
367331 s <- A.scan startState go <* A.anyWord8
368332 case unescapeText (s' <> s) of
369333 Right r -> return r
@@ -376,7 +340,6 @@ data S = S Int# Int#
376340 | otherwise = let a' = c == backslash
377341 in Just a'
378342 where backslash = BACKSLASH
379−#endif
380343
381344decodeWith :: Parser Value -> (Value -> Result a) -> L.ByteString -> Maybe a
382345decodeWith p to s =