basvandijk committed 5f25e28

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.

  • Participants
  • Parent commits 0027f76

Comments (0)

Files changed (1)

File Data/Aeson/Types/Internal.hs

     {-# INLINE gParseRecord #-}
 instance (Selector s, GFromJSON a) => GFromRecord (S1 s a) where
-    gParseRecord obj = case M.lookup (T.pack key) obj of
-                         Nothing -> notFound key
-                         Just v  -> gParseJSON v
+    gParseRecord = maybe (notFound key) gParseJSON . M.lookup (T.pack key)
           key = selName (undefined :: t s a p)
     {-# INLINE gParseRecord #-}