@@ -1,4 +1,3 @@
1−{-# LANGUAGE CPP #-}
21{-# OPTIONS_GHC -fno-warn-orphans #-}
32
43import Blaze.ByteString.Builder (toLazyByteString)
@@ -13,14 +12,6 @@ import qualified Data.Text.Lazy as TL
1312import qualified Data.Text.Lazy.Builder as TLB
1413import qualified Data.Text.Lazy.Encoding as TLE
1514
16−#if !MIN_VERSION_bytestring(0,10,0)
17−import qualified Data.ByteString.Lazy.Internal as BL
18−
19−instance NFData BL.ByteString where
20− rnf (BL.Chunk _ bs) = rnf bs
21− rnf BL.Empty = ()
22−#endif
23−
2415instance (NFData v) => NFData (J.JSObject v) where
2516 rnf o = rnf (J.fromJSObject o)
2617
@@ -46,13 +37,11 @@ decodeA s = case A.decode s of
4637encodeJ :: J.JSValue -> BL.ByteString
4738encodeJ = toLazyByteString . fromString . J.encode
4839
49−#if MIN_VERSION_bytestring(0,10,4)
5040encodeToText :: A.Value -> TL.Text
5141encodeToText = TLB.toLazyText . A.encodeToTextBuilder . A.toJSON
5242
5343encodeViaText :: A.Value -> BL.ByteString
5444encodeViaText = TLE.encodeUtf8 . encodeToText
55−#endif
5645
5746main :: IO ()
5847main = do
@@ -76,18 +65,14 @@ main = do
7665 , bgroup "encode" [
7766 bgroup "en" [
7867 bench "aeson-to-bytestring" $ nf A.encode (decodeA enA)
79−#if MIN_VERSION_bytestring(0,10,4)
8068 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA enA)
8169 , bench "aeson-to-text" $ nf encodeToText (decodeA enA)
82−#endif
8370 , bench "json" $ nf encodeJ (decodeJ enJ)
8471 ]
8572 , bgroup "jp" [
8673 bench "aeson-to-bytestring" $ nf A.encode (decodeA jpA)
87−#if MIN_VERSION_bytestring(0,10,4)
8874 , bench "aeson-via-text-to-bytestring" $ nf encodeViaText (decodeA jpA)
8975 , bench "aeson-to-text" $ nf encodeToText (decodeA jpA)
90−#endif
9176 , bench "json" $ nf encodeJ (decodeJ jpJ)
9277 ]
9378 ]