Perf/ async‑find query‑refinement fast‑path#12053
Conversation
|
Every PR must be linked to a same-repo issue before Oz can review it. Next step: open or find a same-repo issue describing this change, then link it to this PR by adding See the contribution guidelines for the full readiness model. Powered by Oz |
There was a problem hiding this comment.
Every PR must be linked to a same-repo issue before Oz can review it.
Next step: open or find a same-repo issue describing this change, then link it to this PR by adding Closes #123 to the PR description (or using the "Development" sidebar on GitHub). A maintainer will mark the issue ready-to-implement when it is ready. Once it is marked, comment /oz-review to re-trigger review.
See the contribution guidelines for the full readiness model.
Powered by Oz
The async‑find implementation is designed to run a full‑scan of every terminal block every time the user types a new search query.
This works fine for unrelated queries, but it is highly inefficient when the new query is merely a refinement of the previous one (e.g., the user types “foo” and then continues typing “foobar”).
A refinement is a strict prefix: any line that matches “foobar” must have already matched “foo”.
Because of that property we can avoid re‑scanning the whole buffer and instead:
Reuse the matches we already have – only rows that previously contained a match need to be examined again.
Skip blocks with no prior matches – if a block never contributed a match for “foo”, it cannot possibly contain a match for “foobar”.
Finish instantly when the previous result set was empty – there is nothing to rescan