# editor: Improve find_matches and replace_all perf \(\#51941\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/cc279a46fa5ee4e47e27c345a246834a21897c7a)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: cc279a46fa5ee4e47e27c345a246834a21897c7a

Requested commit: cc279a46fa5ee4e47e27c345a246834a21897c7a

Commit: cc279a46fa5ee4e47e27c345a246834a21897c7a

Tree: db3c67088822eef3083b44304740f41707dae7f1

Author: Piotr Osiewicz

Committer: GitHub

## Message

```
editor: Improve find_matches and replace_all perf (#51941)

Helps with https://github.com/zed-industries/zed/issues/38927

- **editor: Add a benchmark for find/replace**
- **text: batch fragment insertions before turning them into a SumTree**

## Context

<!-- What does this PR do, and why? How is it expected to impact users?
     Not just what changed, but what motivated it and why this approach.

Link to Linear issue (e.g., ENG-123) or GitHub issue (e.g., Closes #456)
     if one exists — helps with traceability. -->

## How to Review

<!-- Help reviewers focus their attention:
- For small PRs: note what to focus on (e.g., "error handling in
foo.rs")
- For large PRs (>400 LOC): provide a guided tour — numbered list of
files/commits to read in order. (The `large-pr` label is applied
automatically.)
     - See the review process guidelines for comment conventions -->

## Self-Review Checklist

<!-- Check before requesting review: -->
- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved performance of "Replace All" in buffer search

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
```

## Parents

- [f5945344cc21ebff07eb7ea04dab0555fbe49007](https://git.cafe/gitcafe/zed/commit/f5945344cc21ebff07eb7ea04dab0555fbe49007?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/cc279a46fa5ee4e47e27c345a246834a21897c7a?format=markdown)
