on master help sign in
Static argument transformation for lazy indices

--HG-- extra : convert_revision : 54803f57bc3b147facc996ec60a96ee8ce09514a

commit6f2c86781099aa592e47a51f9b83434af3c7cf62 authorBryan O'Sullivan <bos@serpentine.com> dateWed 8 Sep 2010, 05:32 (16 years ago) parent839b12e
1 file changed+7−5
Data/Text/Lazy/Search.hs+7−5
Data/Text/Lazy/Search.hs+7−5
@@ -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)