From b180ac61a5f6fb06a43da37a82428e1f74ea75d6 Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 6 Aug 2009 11:19:04 +0000 Subject: merge some changes from the latest version of Data.Binary. Makes the binary decoding faster --- src/Data/Binary.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/Data/Binary.hs') diff --git a/src/Data/Binary.hs b/src/Data/Binary.hs index 1b287a099..786f5a09e 100644 --- a/src/Data/Binary.hs +++ b/src/Data/Binary.hs @@ -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 -- cgit v1.2.3