@@ -42,15 +42,17 @@ indices :: Text -- ^ Substring to search for (@needle@)
4242indices needle@(Chunk n ns) _haystack@(Chunk k ks)
4343 | nlen <= 0 = []
4444 | nlen == 1 = indicesOne (nindex 0) 0 k ks
45− | otherwise = scan 0 0 k ks
45+ | otherwise = advance k ks 0 0
4646 where
47− scan !g !i x@(T.Text _ _ l) xs
47+ advance x@(T.Text _ _ l) xs = scan
48+ where
49+ scan !g !i
4850 | i >= m = case xs of
4951 Empty -> []
50− Chunk y ys -> scan g (i-m) y ys
52+ Chunk y ys -> advance y ys g (i-m)
5153 | lackingHay (i + nlen) x xs = []
52− | c == z && candidateMatch 0 = g : scan (g+nlen) (i+nlen) x xs
53− | otherwise = scan (g+delta) (i+delta) x xs
54+ | c == z && candidateMatch 0 = g : scan (g+nlen) (i+nlen)
55+ | otherwise = scan (g+delta) (i+delta)
5456 where
5557 m = fromIntegral l
5658 c = hindex (i + nlast)