Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Multi-row `find`, `find_all` and `mask_matching` slow down with the needle's height; `contains` does not

Open
#647 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
rust

Research direction

Start in screen.rs around for_each_multirow_match (lines 1691–1730) and trace how masked_multiline uses searchable rows. Compare the multirow search path with the joined-text path used by contains, then add a timing test shaped like #584's. Done means find stays within a small factor of contains as the needle height grows.

Written by the indexing model from the issue text.

Description

bug good first issue

What happens. On a 1000x1000 screen where every row is a, with the needle "a\n" * k + "b" (release build):

k contains find
10 4.9 ms 23 ms
100 4.8 ms 176 ms
400 4.4 ms 565 ms

A reviewer measured mask_matching at 690 ms for k = 500.

Cause. for_each_multirow_match (screen.rs:1691-1730) rebuilds searchable_row for every row it compares, for every candidate start row. Its cost grows as rows × needle rows × columns. contains searches the joined text once.

Why it matters. #584 removed the quadratic behaviour from single-row search. Multi-row needles still have it. The impact is small, since the worst case needs a needle hundreds of rows tall.

Fix. Compute each row's searchable form once per call, as Vec<(String, Vec<u16>)>, and share it with masked_multiline.

Done when find stays within a small factor of contains as k grows, with a timing test in the shape of #584's.

Dominant language
Rust
Stars
28
Forks
24
Avg merge
11h 23m
Merged PRs (30d)
42

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vyncint/termlens

All issues in vyncint/termlens

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.