on master help sign in
Make toList independent of array length

--HG-- extra : convert_revision : 4e48d683a02577309e5ebd1d9acb95d1ea1b0e7f

commit20530e332114a9200d2fcdda9ab68867e2d0e03d authorBryan O'Sullivan <bos@serpentine.com> dateSun 29 Aug 2010, 06:06 (16 years ago) parent423564d
2 files changed+4−5
Data/Text/Array.hs+3−4 Data/Text/Internal.hs+1−1
Data/Text/Array.hs+3−4
@@ -172,11 +172,10 @@ unsafeWriteWord MArray{..} i@(I# i#) (W# e#) = ST $ \s1# ->
172172{-# INLINE unsafeWriteWord #-}
173173
174174-- | Convert an immutable array to a list.
175−toList :: Array -> [Word16]
176−toList a = loop 0
177− where loop i | i < len = unsafeIndex a i : loop (i+1)
175+toList :: Array -> Int -> Int -> [Word16]
176+toList ary off len = loop 0
177+ where loop i | i < len = unsafeIndex ary (off+i) : loop (i+1)
178178 | otherwise = []
179− len = length a
180179
181180-- | An empty immutable array.
182181empty :: Array
Data/Text/Internal.hs+1−1
@@ -70,5 +70,5 @@ textP arr off len | len == 0 = empty
7070-- | A useful 'show'-like function for debugging purposes.
7171showText :: Text -> String
7272showText (Text arr off len) =
73− "Text " ++ (show . take (off+len) . A.toList) arr ++ ' ' :
73+ "Text " ++ show (A.toList arr off len) ++ ' ' :
7474 show off ++ ' ' : show len