[Haskell-cafe] Array copy performance

Chris Kuklewicz haskell at list.mightyreason.com
Fri Feb 2 08:44:37 EST 2007


Hi,

  I am trying to improve the memory usage of regex-tdfa and I wanted to ask an
array question.

If I have two identical STUArrays (same type and bounds) then what is the most
efficient way to overwrite the data in the destination with the data in the
source?  Does this work for STArrays? Is there a GHC only solution?

Is there a way to avoid the long loop?
>   forM_ (range b) $ \index ->
>     readArray source index >>= writeArray destination index

Is Data.Array.Storable the only route?

I do not think Data.Array.Diff will work well since I have one source going to
multiple destinations, each with a few different changes.

-- 
Chris


More information about the Haskell-Cafe mailing list