[Haskell-cafe] Re: Pickling a finite map (Binary + zlib) [was:
Data.Binary poor read performance]
Christian Maeder
Christian.Maeder at dfki.de
Tue Feb 24 13:46:28 EST 2009
>> fromDistinctAscList :: [(k,a)] -> Map k a
>> fromDistinctAscList xs
>> = build const (length xs) xs
>> where
>> -- 1) use continutations so that we use heap space instead of stack space.
>> -- 2) special case for n==5 to build bushier trees.
>> build c 0 xs' = c Tip xs'
>> build c 5 xs' = case xs' of
>> ((k1,x1):(k2,x2):(k3,x3):(k4,x4):(k5,x5):xx)
>> -> c (bin k4 x4 (bin k2 x2 (singleton k1
>> x1) (singleton k3 x3)) (singleton k5 x5)) xx
By the way, did anyone test if (or when) this n==5 case "bushier trees"
gains something?
Thanks Christian
More information about the Haskell-Cafe
mailing list