Skip to content
Snippets Groups Projects
Commit 66e2bd09 authored by Bodigrim's avatar Bodigrim
Browse files

Review suggestions

parent ca9bee8d
No related branches found
No related tags found
No related merge requests found
...@@ -45,9 +45,7 @@ import System.Posix.Types (CSsize(..)) ...@@ -45,9 +45,7 @@ import System.Posix.Types (CSsize(..))
data T = {-# UNPACK #-} !Word64 :* {-# UNPACK #-} !Int data T = {-# UNPACK #-} !Word64 :* {-# UNPACK #-} !Int
-- | /O(n+m)/ Find the offsets of all non-overlapping indices of -- | /O(n+m)/ Find the offsets of all non-overlapping indices of
-- @needle@ within @haystack@. The offsets returned represent -- @needle@ within @haystack@.
-- uncorrected indices in the low-level \"needle\" array, to which its
-- offset must be added.
-- --
-- In (unlikely) bad cases, this algorithm's complexity degrades -- In (unlikely) bad cases, this algorithm's complexity degrades
-- towards /O(n*m)/. -- towards /O(n*m)/.
...@@ -66,7 +64,7 @@ indices' (Text narr noff nlen) (Text harr@(A.ByteArray harr#) hoff hlen) = loop ...@@ -66,7 +64,7 @@ indices' (Text narr noff nlen) (Text harr@(A.ByteArray harr#) hoff hlen) = loop
where where
nlast = nlen - 1 nlast = nlen - 1
!z = nindex nlast !z = nindex nlast
nindex k = if k < 0 then 0 else A.unsafeIndex narr (noff+k) nindex k = A.unsafeIndex narr (noff+k)
buildTable !i !msk !skp buildTable !i !msk !skp
| i >= nlast = (msk .|. swizzle z) :* skp | i >= nlast = (msk .|. swizzle z) :* skp
| otherwise = buildTable (i+1) (msk .|. swizzle c) skp' | otherwise = buildTable (i+1) (msk .|. swizzle c) skp'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment