Commit 15532cb1 authored by simonpj's avatar simonpj
Browse files

[project @ 2004-05-27 11:32:03 by simonpj]

Inline the default method for newArray; big perf boost; comments with the pragma
parent 9eef5c0b
......@@ -968,6 +968,10 @@ class (HasBounds a, Monad m) => MArray a e m where
unsafeRead :: Ix i => a i e -> Int -> m e
unsafeWrite :: Ix i => a i e -> Int -> e -> m ()
{-# INLINE newArray #-}
-- The INLINE is crucial, because until we know at least which monad
-- we are in, the code below allocates like crazy. So inline it,
-- in the hope that the context will know the monad.
newArray (l,u) init = do
marr <- newArray_ (l,u)
sequence_ [unsafeWrite marr i init | i <- [0 .. rangeSize (l,u) - 1]]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment