Skip to content

renderer: avoid allocating when there are no active links - #13258

Merged
mitchellh merged 1 commit into
ghostty-org:mainfrom
jparise:inactive-links
Jul 9, 2026
Merged

mitchellh merged 1 commit into
ghostty-org:mainfrom
jparise:inactive-links

Conversation

@jparise

@jparise jparise commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Determine if any links are active before building the string and byte-to-cell map. Those buffers scale with viewport size, and this function runs during frame updates, so avoid allocating them when the current mouse/modifier state can't highlight any regex links.

This adds an additional self.links iteration, but that list is usually small, the "active" check is cheap, and it breaks on the first hit.


GPT 5.5 spotted this and wrote the test case. I came up with the tradeoffs myself and wrote the runtime code.

@jparise
jparise requested a review from a team as a code owner July 9, 2026 15:17
@ghostty-bot ghostty-bot Bot added the renderer label Jul 9, 2026
Determine if any links are active before building the string and
byte-to-cell map. Those buffers scale with viewport size, and this
function runs during frame updates, so avoid allocating them when the
current mouse/modifier state can't highlight any regex links.

This adds an additional `self.links` iteration, but that list is usually
small, the "active" check is cheap, and it breaks on the first hit.
@mitchellh
mitchellh merged commit 7cb44fe into ghostty-org:main Jul 9, 2026
92 of 94 checks passed
@github-actions github-actions Bot added this to the 1.4.0 milestone Jul 9, 2026
@jparise
jparise deleted the inactive-links branch July 9, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants