merge some changes from the latest version of Data.Binary. Makes the binary decoding faster

This commit is contained in:
krasimir
2009-08-06 11:19:04 +00:00
parent 3473f0d274
commit b180ac61a5
3 changed files with 48 additions and 30 deletions

View File

@@ -734,9 +734,13 @@ instance (Binary e) => Binary (IntMap.IntMap e) where
--
instance (Binary e) => Binary (Seq.Seq e) where
-- any better way to do this?
put = put . Fold.toList
get = fmap Seq.fromList get
put s = put (Seq.length s) >> Fold.mapM_ put s
get = do n <- get :: Get Int
rep Seq.empty n get
where rep xs 0 _ = return $! xs
rep xs n g = xs `seq` n `seq` do
x <- g
rep (xs Seq.|> x) (n-1) g
#endif