on master help sign in
Comment and whitespace tidyups
889b318Bryan O'Sullivan
Data/Text.hs+8−6
@@ -302,9 +302,9 @@ second f (a, b) = (a, f b)
302-- non-empty. Subject to array fusion.
302-- non-empty. Subject to array fusion.
303last :: Text -> Char
303last :: Text -> Char
304last (Text arr off len)
304last (Text arr off len)
305− | len <= 0 = errorEmptyList "last"
305+ | len <= 0 = errorEmptyList "last"
306 | n < 0xDC00 || n > 0xDFFF = unsafeChr n
306 | n < 0xDC00 || n > 0xDFFF = unsafeChr n
307− | otherwise = U16.chr2 n0 n
307+ | otherwise = U16.chr2 n0 n
308 where
308 where
309 n = A.unsafeIndex arr (off+len-1)
309 n = A.unsafeIndex arr (off+len-1)
310 n0 = A.unsafeIndex arr (off+len-2)
310 n0 = A.unsafeIndex arr (off+len-2)
@@ -566,15 +566,17 @@ drop n t@(Text arr off len)
566 unstream (S.drop n (stream t)) = drop n t
566 unstream (S.drop n (stream t)) = drop n t
567 #-}
567 #-}
568
568
569−-- | 'takeWhile', applied to a predicate @p@ and a 'Text', returns the
569+-- | /O(n)/ 'takeWhile', applied to a predicate @p@ and a 'Text', returns the
570-- longest prefix (possibly empty) of elements that satisfy @p@.
570-- longest prefix (possibly empty) of elements that satisfy @p@.
571takeWhile :: (Char -> Bool) -> Text -> Text
571takeWhile :: (Char -> Bool) -> Text -> Text
572takeWhile p t = unstream (S.takeWhile p (stream t))
572takeWhile p t = unstream (S.takeWhile p (stream t))
573+{-# INLINE takeWhile #-}
573
574
574−-- | 'dropWhile' @p@ @xs@ returns the suffix remaining after
575+-- | /O(n)/ 'dropWhile' @p@ @xs@ returns the suffix remaining after
575-- 'takeWhile' @p@ @xs@.
576-- 'takeWhile' @p@ @xs@.
576dropWhile :: (Char -> Bool) -> Text -> Text
577dropWhile :: (Char -> Bool) -> Text -> Text
577dropWhile p t = unstream (S.dropWhile p (stream t))
578dropWhile p t = unstream (S.dropWhile p (stream t))
579+{-# INLINE dropWhile #-}
578
580
579-- | /O(n)/ Return all initial segments of the given 'Text', shortest
581-- | /O(n)/ Return all initial segments of the given 'Text', shortest
580-- first.
582-- first.
@@ -584,8 +586,8 @@ inits (Text arr off len) = [Text arr off l | l <- [0..len]]
584-- | /O(n)/ Return all final segments of the given 'Text', longest
586-- | /O(n)/ Return all final segments of the given 'Text', longest
585-- first.
587-- first.
586tails :: Text -> [Text]
588tails :: Text -> [Text]
587−tails p | null p = [empty]
589+tails t | null t = [empty]
588− | otherwise = p : tails (tail p)
590+ | otherwise = t : tails (tail t)
589
591
590-- ----------------------------------------------------------------------------
592-- ----------------------------------------------------------------------------
591-- * Searching
593-- * Searching