Commits

dafis committed 460b877 Merge

Merge with Bryan

Comments (0)

Files changed (1)

Data/Text/Lazy/Search.hs

 -- past the end.
 index :: T.Text -> Text -> Int64 -> Word16
 index (T.Text arr off len) xs !i
-    | j < len   = A.unsafeIndex arr (off+j)
+    | i < wlen  = A.unsafeIndex arr (off+j)
     | otherwise = case xs of
                     Empty
                         -- out of bounds, but legal
                         | j == len  -> 0
                         -- should never happen, due to lackingHay above
                         | otherwise -> emptyError "index"
-                    Chunk c cs -> index c cs (i-fromIntegral len)
+                    Chunk c cs -> index c cs (i-wlen)
     where j = fromIntegral i
+          wlen = fromIntegral len
 
 -- | A variant of 'indices' that scans linearly for a single 'Word16'.
 indicesOne :: Word16 -> Int64 -> T.Text -> Text -> [Int64]