# editor: Improve performance of \`create_highlight_endpoints\` \(\#44521\) · gitcafe/zed

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

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

Visibility: public

Requested revision: b1333b53ad6595e12587e8bbc58509fb2551bc43

Requested commit: b1333b53ad6595e12587e8bbc58509fb2551bc43

Commit: b1333b53ad6595e12587e8bbc58509fb2551bc43

Tree: f5db5096d824fcd451595f10b734390cac2d1531

Author: Lukas Wirth

Committer: GitHub

## Message

```
editor: Improve performance of `create_highlight_endpoints` (#44521)

We reallocate quite a bunch in this codepath even though we don't need
to, we already roughly know what number of elements we are working with
so we can reduce the required allocations to some degree. This also
reduces the amount of anchor comparisons required.

Came up in profiling for
https://github.com/zed-industries/zed/issues/44503

Release Notes:

- N/A *or* Added/Fixed/Improved ...
```

## Parents

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

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