move buffer around when calling 'SearchList.buildRange'

This commit is contained in:
2025-09-30 05:40:57 +01:00
parent e03eecf940
commit 45fbd85183
4 changed files with 18 additions and 15 deletions

View File

@@ -171,11 +171,12 @@ struct
local
fun loop (pos, buffer, nfa, origNfa, startPos, acc, lastIdx) =
if pos = #textLength buffer then
acc
(buffer, acc)
else if pos > lastIdx then
acc
(buffer, acc)
else
let
val buffer = LineGap.goToIdx (pos, buffer)
val chr = LineGap.sub (pos, buffer)
val (nfa, state) = rebuild (nfa, chr, pos)
in
@@ -202,7 +203,6 @@ struct
loop (pos + 1, buffer, nfa, origNfa, startPos, acc, lastIdx)
end
in
(* Prerequisite: move buffer to 'start' parameter before calling *)
fun getMatchesInRange (startIdx, finishIdx, buffer: LineGap.t, nfa) =
loop (startIdx, buffer, nfa, nfa, 0, PersistentVector.empty, finishIdx)
end