Commits

Bryan O'Sullivan committed 9fffb72

Static argument transformation for lazy indices

Comments (0)

Files changed (1)

Data/Text/Lazy/Search.hs

 indices needle@(Chunk n ns) _haystack@(Chunk k ks)
     | nlen <= 0  = []
     | nlen == 1  = indicesOne (nindex 0) 0 k ks
-    | otherwise  = scan 0 0 k ks
+    | otherwise  = advance k ks 0 0
   where
-    scan !g !i x@(T.Text _ _ l) xs
+    advance x@(T.Text _ _ l) xs = scan
+     where
+      scan !g !i
          | i >= m = case xs of
                       Empty           -> []
-                      Chunk y ys      -> scan g (i-m) y ys
+                      Chunk y ys      -> advance y ys g (i-m)
          | lackingHay (i + nlen) x xs  = []
-         | c == z && candidateMatch 0  = g : scan (g+nlen) (i+nlen) x xs
-         | otherwise                   = scan (g+delta) (i+delta) x xs
+         | c == z && candidateMatch 0  = g : scan (g+nlen) (i+nlen)
+         | otherwise                   = scan (g+delta) (i+delta)
        where
          m = fromIntegral l
          c = hindex (i + nlast)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.