Commits

Bryan O'Sullivan  committed 0ae9d4e

Experimental HashMap fun

Makes parsing about 5% faster

  • Participants
  • Parent commits 464092c
  • Branches hashmap

Comments (0)

Files changed (4)

File Data/Aeson/Encode.hs

 import Numeric (showHex)
 import qualified Data.ByteString.Char8 as B
 import qualified Data.ByteString.Lazy.Char8 as L
-import qualified Data.Map as M
+import qualified Data.HashMap as M
 import qualified Data.Text as T
 import qualified Data.Vector as V
 

File Data/Aeson/Parser.hs

 import Data.Bits ((.|.), shiftL)
 import Data.ByteString as B
 import Data.Char (chr)
-import Data.Map as Map
+import Data.HashMap as Map
 import Data.Monoid (mappend, mempty)
 import Data.Text as T
 import Data.Text.Encoding (decodeUtf8)

File Data/Aeson/Types.hs

 
 import Control.Applicative
 import Control.DeepSeq (NFData(..))
-import Data.Map (Map)
+import Data.HashMap (HashMap)
 import qualified Data.ByteString as B
 import qualified Data.ByteString.Lazy as LB
 import Data.Text.Encoding (decodeUtf8, encodeUtf8)
 import Data.Typeable (Typeable)
 import Data.Vector (Vector)
 import System.Locale (defaultTimeLocale)
-import qualified Data.Map as M
+import qualified Data.HashMap as M
 import qualified Data.Vector as V
 
-type Object = Map Text Value
+type Object = HashMap Text Value
 type Array = Vector Value
 
 -- | A JSON value represented as a Haskell value.
 -- | Create a 'Value' from a list of 'Object's.  If duplicate
 -- keys arise, earlier keys and their associated values win.
 object :: [Object] -> Value
-object = Object . M.unions
+object = Object . M.fromList . concat . map M.toList
 {-# INLINE object #-}
 
 -- | A type that can be converted to JSON.
     base == 4.*,
     blaze-builder >= 0.2.1.4,
     bytestring,
-    containers,
+    unordered-containers,
     deepseq,
     old-locale,
     text >= 0.11.0.2,