diff --git a/src/Data/Text/Internal/Search.hs b/src/Data/Text/Internal/Search.hs index 7c2b85b333641d5cb3aa2f31df58f5f824e28958..1d063e47d77dfaaeb74c2335329a7aa4f4057471 100644 --- a/src/Data/Text/Internal/Search.hs +++ b/src/Data/Text/Internal/Search.hs @@ -45,9 +45,7 @@ import System.Posix.Types (CSsize(..)) data T = {-# UNPACK #-} !Word64 :* {-# UNPACK #-} !Int -- | /O(n+m)/ Find the offsets of all non-overlapping indices of --- @needle@ within @haystack@. The offsets returned represent --- uncorrected indices in the low-level \"needle\" array, to which its --- offset must be added. +-- @needle@ within @haystack@. -- -- In (unlikely) bad cases, this algorithm's complexity degrades -- towards /O(n*m)/. @@ -66,7 +64,7 @@ indices' (Text narr noff nlen) (Text harr@(A.ByteArray harr#) hoff hlen) = loop where nlast = nlen - 1 !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 | i >= nlast = (msk .|. swizzle z) :* skp | otherwise = buildTable (i+1) (msk .|. swizzle c) skp'