on master help sign in
Improved performance of generic parseJSON of records by a factor of 3

simply by writing the function in pointfree style. This probably enables GHC to inline the function better.

commit8ba8f84b3101976d755e27095d844617936a542d authorBas van Dijk <v.dijk.bas@gmail.com> dateThu 3 Nov 2011, 00:03 (15 years ago) parent3022d25
1 file changed+1−3
Data/Aeson/Types/Internal.hs+1−3
Data/Aeson/Types/Internal.hs+1−3
@@ -1091,9 +1091,7 @@ instance (GFromRecord a, GFromRecord b) => GFromRecord (a :*: b) where
10911091 {-# INLINE gParseRecord #-}
10921092
10931093instance (Selector s, GFromJSON a) => GFromRecord (S1 s a) where
1094− gParseRecord obj = case M.lookup (T.pack key) obj of
1095− Nothing -> notFound key
1096− Just v -> gParseJSON v
1094+ gParseRecord = maybe (notFound key) gParseJSON . M.lookup (T.pack key)
10971095 where
10981096 key = selName (undefined :: t s a p)
10991097 {-# INLINE gParseRecord #-}