@@ -940,10 +940,12 @@ find :: Text -- ^ @needle@ to search for
940940 -> [(Text, Text)]
941941find pat src
942942 | null pat = emptyError "find"
943− | otherwise = L.map step (indices pat src)
943+ | otherwise = go 0 empty src (indices pat src)
944944 where
945− step x = let h :*: t = splitAtWord x src
946− in (h, t)
945+ go !n p s (x:xs) = let h :*: t = splitAtWord (x-n) s
946+ h' = append p h
947+ in (h',t) : go x h' t xs
948+ go _ _ _ _ = []
947949
948950-- | /O(n)/ 'breakBy' is like 'spanBy', but the prefix returned is over
949951-- elements that fail the predicate @p@.