# editor: Use less memory when replacing literal strings \(\#46092\) · gitcafe/zed

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

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

Visibility: public

Requested revision: f35e67894d5c34c7ae5b04396c9fdbc49e6c8a8c

Requested commit: f35e67894d5c34c7ae5b04396c9fdbc49e6c8a8c

Commit: f35e67894d5c34c7ae5b04396c9fdbc49e6c8a8c

Tree: d65f12d62adb8d3d5cf2abb86565648bdf0ef50c

Author: Marco Mihai Condrache

Committer: GitHub

## Message

```
editor: Use less memory when replacing literal strings (#46092)

Found while profiling #38927

When the query is not a regex, the same replacement can be applied to
all matches. Previously, `replacement_for` allocated a new String on
every call, while `replacement` returns a reference.

Release Notes:

- N/A

---------

Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
```

## Parents

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

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