Commits

Bryan O'Sullivan committed e2bf37d

Make toList independent of array length

  • Participants
  • Parent commits d07e884

Comments (0)

Files changed (2)

Data/Text/Array.hs

 {-# INLINE unsafeWriteWord #-}
 
 -- | Convert an immutable array to a list.
-toList :: Array -> [Word16]
-toList a = loop 0
-    where loop i | i < len   = unsafeIndex a i : loop (i+1)
+toList :: Array -> Int -> Int -> [Word16]
+toList ary off len = loop 0
+    where loop i | i < len   = unsafeIndex ary (off+i) : loop (i+1)
                  | otherwise = []
-          len = length a
 
 -- | An empty immutable array.
 empty :: Array

Data/Text/Internal.hs

 -- | A useful 'show'-like function for debugging purposes.
 showText :: Text -> String
 showText (Text arr off len) =
-    "Text " ++ (show . take (off+len) . A.toList) arr ++ ' ' :
+    "Text " ++ show (A.toList arr off len) ++ ' ' :
             show off ++ ' ' : show len