mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-19 06:59:22 +01:00
5f27a0a02a
## Summary The string and path-set matchers in `fuzzy` and `fuzzy_nucleo` collect matches per segment. They merged the segments with `segment_results.concat()`, which clones every element. Each match was copied (a `String` and a `Vec` for `fuzzy::StringMatch`) and the original dropped, before the results were truncated to `max_results`. This moves the matches. `cargo bench -p fuzzy_nucleo --bench match_benchmark`, string matching with 1-word queries: | Benchmark | Before | After | |---|---|---| | `1-word/fuzzy/1000` | 67.9 µs | 58.4 µs | | `1-word/fuzzy/10000` | 532 µs | 444 µs | | `1-word/nucleo/1000` | 67.2 µs | 62.0 µs | | `1-word/nucleo/10000` | 472 µs | 406 µs | The 2- and 4-word groups match fewer candidates and improved by 2% to 22%. The path groups in that benchmark use `match_fixed_path_set`, which this does not change. A copy of the merge step outside Zed, merging 10,000 `StringMatch` values from 16 segments: 412 µs before, 75 µs after. ## Testing `cargo test -p fuzzy --features path/test-support`, `cargo test -p fuzzy_nucleo`, and `cargo test -p file_finder --lib` pass. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - Improved fuzzy matching performance when many candidates match