on master help sign in
Make toList independent of array length
20530e3Bryan O'Sullivan
Data/Text/Array.hs+3−4
@@ -172,11 +172,10 @@ unsafeWriteWord MArray{..} i@(I# i#) (W# e#) = ST $ \s1# ->
172{-# INLINE unsafeWriteWord #-}
172{-# INLINE unsafeWriteWord #-}
173
173
174-- | Convert an immutable array to a list.
174-- | Convert an immutable array to a list.
175−toList :: Array -> [Word16]
175+toList :: Array -> Int -> Int -> [Word16]
176−toList a = loop 0
176+toList ary off len = loop 0
177− where loop i | i < len = unsafeIndex a i : loop (i+1)
177+ where loop i | i < len = unsafeIndex ary (off+i) : loop (i+1)
178 | otherwise = []
178 | otherwise = []
179− len = length a
180
179
181-- | An empty immutable array.
180-- | An empty immutable array.
182empty :: Array
181empty :: Array
Data/Text/Internal.hs+1−1
@@ -70,5 +70,5 @@ textP arr off len | len == 0 = empty
70-- | A useful 'show'-like function for debugging purposes.
70-- | A useful 'show'-like function for debugging purposes.
71showText :: Text -> String
71showText :: Text -> String
72showText (Text arr off len) =
72showText (Text arr off len) =
73− "Text " ++ (show . take (off+len) . A.toList) arr ++ ' ' :
73+ "Text " ++ show (A.toList arr off len) ++ ' ' :
74 show off ++ ' ' : show len
74 show off ++ ' ' : show len