From 801734dc5a41c57659f90cadb6c2c986b304e9f0 Mon Sep 17 00:00:00 2001 From: simonpj Date: Thu, 27 May 2004 11:32:03 +0000 Subject: [PATCH] [project @ 2004-05-27 11:32:03 by simonpj] Inline the default method for newArray; big perf boost; comments with the pragma --- Data/Array/Base.hs | 4 ++++ 1 file changed, 4 insertions(+) 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]] -- 1.7.10.4