@@ -125,7 +125,6 @@ module Data.Text
125125 -- ** Breaking into many substrings
126126 -- $split
127127 , split
128− , splitTimesEnd
129128 , splitBy
130129 , chunksOf
131130
@@ -933,58 +932,6 @@ split pat@(Text _ _ l) src@(Text arr off len)
933932 split (singleton c) t = splitBy (==c) t
934933 #-}
935934
936−-- | /O(m+n)/ Break a 'Text' into pieces at most @k@ times,
937−-- treating the first 'Text' argument as the delimiter to break on,
938−-- and consuming the delimiter. The last element of the list contains
939−-- the remaining text after the number of times to split has been
940−-- reached. A value of zero or less for @k@ causes no splitting to
941−-- occur. An empty delimiter is invalid, and will cause an error to be
942−-- raised.
943−--
944−-- Examples:
945−--
946−-- > splitTimes 0 "//" "a//b//c" == ["a//b//c"]
947−-- > splitTimes 2 ":" "a:b:c:d:e" == ["a","b","c:d:e"]
948−-- > splitTimes 100 "???" "a????b" == ["a","?b"]
949−--
950−-- and
951−--
952−-- > intercalate s . splitTimes k s == id
953−--
954−-- In (unlikely) bad cases, this function's time complexity
955−-- degenerates towards /O(n*m)/.
956−splitTimes :: Int -- ^ Maximum number of times to split
957− -> Text -- ^ Text to split on
958− -> Text -- ^ Input text
959− -> [Text]
960−splitTimes k pat@(Text _ _ l) src@(Text arr off len)
961− | l <= 0 = emptyError "splitTimes"
962− | otherwise = go 0 0 (indices pat src)
963− where
964− go !s !i _ | i >= k = [textP arr (s+off) (len-s)]
965− go !s _ [] = [textP arr (s+off) (len-s)]
966− go !s !i (x:xs) = textP arr (s+off) (x-s) : go (x+l) (i+1) xs
967−{-# INLINE splitTimes #-}
968−
969−-- | /O(m+n)/ Break a 'Text' into pieces at most @k@ times, like
970−-- 'splitTimes', but start from the end of the input and work towards
971−-- the start.
972−--
973−-- Examples:
974−--
975−-- > splitTimes 2 "::" "a::b::c::d::e" == ["a","b","c::d::e"]
976−-- > splitTimesEnd 2 "::" "a::b::c::d::e" == ["a::b::c","d","e"]
977−--
978−-- In (unlikely) bad cases, this function's time complexity
979−-- degenerates towards /O(n*m)/.
980−splitTimesEnd :: Int -- ^ Maximum number of times to split
981− -> Text -- ^ Text to split on
982− -> Text -- ^ Input text
983− -> [Text]
984−splitTimesEnd k pat src =
985− L.reverse . L.map reverse $ splitTimes k (reverse pat) (reverse src)
986−{-# INLINE splitTimesEnd #-}
987−
988935-- | /O(n)/ Splits a 'Text' into components delimited by separators,
989936-- where the predicate returns True for a separator element. The
990937-- resulting components do not contain the separators. Two adjacent