on master help sign in
Simplify (and probably speed up) some code a little
commit8048623c2efe98db31be40247e740d30f50a1a33 authorBryan O'Sullivan <bos@serpentine.com> dateFri 4 Feb 2011, 21:13 (16 years ago) parentcf2365c
1 file changed+3−4
Data/Aeson/Generic.hs+3−4
Data/Aeson/Generic.hs+3−4
@@ -211,7 +211,7 @@ parseJSON_generic j = generic
211211 | n > 1 = construct c (V.toList js) -- no field names
212212 -- FIXME? We could allow reading an array into a constructor
213213 -- with field names.
214− go _ c fs@(_:_) (Object o) = selectFields (fromJSObject o) fs >>=
214+ go _ c fs@(_:_) (Object o) = selectFields o fs >>=
215215 construct c -- field names
216216 go _ c _ jd = modFail "parseJSON" $
217217 "bad decodeArgs data " ++ show (c, jd)
@@ -226,11 +226,10 @@ parseJSON_generic j = generic
226226 [] -> lift $ modFail "construct" "empty list"
227227 (j':js') -> do put js'; lift $ parseJSON j'
228228
229− -- Select the named fields from a JSON object. FIXME? Should
230− -- this use a map?
229+ -- Select the named fields from a JSON object.
231230 selectFields fjs = mapM sel
232231 where sel f = maybe (modFail "parseJSON" $ "field does not exist " ++
233− f) return $ lookup f fjs
232+ f) return $ Map.lookup (pack f) fjs
234233
235234 -- Count how many arguments a constructor has. The value x is
236235 -- used to determine what type the constructor returns.