[karp-rabin] fix performance

parent 31ea9ab7
......@@ -192,12 +192,12 @@ strictMatcher { hash, hashMap, hLen, pats, rehash } = unsafePartial search
go :: GoAcc -> Tuple Int (Array CodePoint) -> GoAcc
go (Tuple h acc) (Tuple idx arr') =
let rehashed = rehash h (fromJust $ A.head arr') (fromJust $ A.last arr')
-- str' = S.fromCodePointArray arr'
str' = S.drop idx str
okay bs = isJust (S.stripPrefix (S.Pattern bs) str')
el = case M.lookup h hashMap of
Nothing -> Nothing
Just ps ->
let str' = S.drop idx str
okay bs = isJust (S.stripPrefix (S.Pattern bs) str')
in
case A.filter (\x -> okay (A.unsafeIndex pats x)) ps of
[] -> Nothing
qs -> Just (Tuple idx qs)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment