From: simonpj Date: Thu, 27 May 2004 11:32:03 +0000 (+0000) Subject: [project @ 2004-05-27 11:32:03 by simonpj] X-Git-Tag: nhc98-1-18-release~318 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=801734dc5a41c57659f90cadb6c2c986b304e9f0;p=haskell-directory.git [project @ 2004-05-27 11:32:03 by simonpj] Inline the default method for newArray; big perf boost; comments with the pragma --- diff --git a/Data/Array/Base.hs b/Data/Array/Base.hs index cb57dca..61e89e4 100644 --- a/Data/Array/Base.hs +++ b/Data/Array/Base.hs @@ -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]]