on master help sign in
Merge pull request #479 from niteria/specialize-common

Specialize ToJSON for common types

commit47a3a2c06c62fad8056cd844104fa7f5bbfb2529 authorAdam Bergmark <adam@bergmark.nl> dateTue 6 Dec 2016, 17:04 (10 years ago) parentadf965780b72b3
1 file changed+9
Data/Aeson/Types/ToJSON.hs+9
Data/Aeson/Types/ToJSON.hs+9
@@ -615,6 +615,11 @@ instance ToJSON1 [] where
615615 {-# INLINE liftToEncoding #-}
616616
617617instance (ToJSON a) => ToJSON [a] where
618+ {-# SPECIALIZE instance ToJSON String #-}
619+ {-# SPECIALIZE instance ToJSON [String] #-}
620+ {-# SPECIALIZE instance ToJSON [Array] #-}
621+ {-# SPECIALIZE instance ToJSON [Object] #-}
622+
618623 toJSON = toJSON1
619624 {-# INLINE toJSON #-}
620625
@@ -1865,6 +1870,8 @@ instance ToJSON1 Vector where
18651870 {-# INLINE liftToEncoding #-}
18661871
18671872instance (ToJSON a) => ToJSON (Vector a) where
1873+ {-# SPECIALIZE instance ToJSON Array #-}
1874+
18681875 toJSON = toJSON1
18691876 {-# INLINE toJSON #-}
18701877
@@ -1936,6 +1943,8 @@ instance ToJSONKey k => ToJSON1 (H.HashMap k) where
19361943 {-# INLINE liftToEncoding #-}
19371944
19381945instance (ToJSON v, ToJSONKey k) => ToJSON (H.HashMap k v) where
1946+ {-# SPECIALIZE instance ToJSON Object #-}
1947+
19391948 toJSON = toJSON1
19401949 {-# INLINE toJSON #-}
19411950