# terminal: Fix performance issues with hyperlink regex matching \(\#44407\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 3d6cc3dc791f2ffdcc1953c2dcd417099b07280e

Requested commit: 3d6cc3dc791f2ffdcc1953c2dcd417099b07280e

Commit: 3d6cc3dc791f2ffdcc1953c2dcd417099b07280e

Tree: 6731f1f0de1d95f1d8ad3ee981a2791ca9c80599

Author: Piotr Osiewicz

Committer: GitHub

## Message

```
terminal: Fix performance issues with hyperlink regex matching (#44407)

Problem statement: When given a line that contained a lot of matches of
your hyperlink regex of choice (thanks to #40305), we would look for
matches
that intersected with currently hovered point. This is *hella*
expensive, because we would re-walk the whole alacritty grid for each
match. With the repro that Joseph shared, we had to go through 4000 such
matches on each frame render.

Problem solution: We now convert the hovered point into a range within
the line (byte-wise) in order to throw away matches that do not
intersect the
hovered range. This lets us avoid performing the unnecessary conversion
when we know it's never going to yield a match range that intersects the
hovered point.

Release Notes:

- terminal: Fixed performance regression when handling long lines.

---------

Co-authored-by: Dave Waggoner <waggoner.dave@gmail.com>
```

## Parents

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

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