@@ -47,9 +47,9 @@ indices :: Text -- ^ Substring to search for (@needle@)
4747 -> Text -- ^ Text to search in (@haystack@)
4848 -> [Int]
4949indices _needle@(Text narr noff nlen) _haystack@(Text harr hoff hlen)
50− | nlen == 1 = scanOne (nindex 0)
51− | nlen <= 0 || ldiff < 0 = []
52− | otherwise = scan 0
50+ | nlen == 1 = scanOne (nindex 0)
51+ | nlen <= 0 || ldiff < 0 = []
52+ | otherwise = scan 0
5353 where
5454 ldiff = hlen - nlen
5555 nlast = nlen - 1
@@ -63,21 +63,20 @@ indices _needle@(Text narr noff nlen) _haystack@(Text harr hoff hlen)
6363 where c = nindex i
6464 skp' | c == z = nlen - i - 2
6565 | otherwise = skp
66− swizzle k = 1 `shiftL` (fromEnum k .&. 0x3f)
66+ swizzle k = 1 `shiftL` (fromIntegral k .&. 0x3f)
6767 scan !i
6868 | i > ldiff = []
6969 | c == z && candidateMatch 0 = i : scan (i + nlast)
7070 | otherwise = scan (i + delta)
71− where c = hindex (i + nlast)
72− candidateMatch j
73− | j >= nlast = True
74− | hindex (i+j) /= nindex j = False
75− | otherwise = candidateMatch (j+1)
76− delta
77− | nextInPattern = nlen + 1
78− | c == z = skip + 1
79− | otherwise = 1
80− nextInPattern = (mask .&. swizzle (hindex (i+nlen))) == 0
71+ where c = hindex (i + nlast)
72+ candidateMatch !j
73+ | j >= nlast = True
74+ | hindex (i+j) /= nindex j = False
75+ | otherwise = candidateMatch (j+1)
76+ delta | nextInPattern = nlen + 1
77+ | c == z = skip + 1
78+ | otherwise = 1
79+ nextInPattern = mask .&. swizzle (hindex (i+nlen)) == 0
8180 scanOne c = loop 0
8281 where loop !i | i >= hlen = []
8382 | hindex i == c = i : loop (i+1)