Bryan O'Sullivan avatar Bryan O'Sullivan committed 0ae9d4e

Experimental HashMap fun

Makes parsing about 5% faster

Comments (0)

Files changed (4)

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
 

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)

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,
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.