ZIm/crates/gpui/src/text_system
Piotr Osiewicz 5447821715
gpui/perf: Use SharedString on API boundary of line layout (#22566)
This commit is all about strings, not about line layout at all. When
laying out text, we use a line layout cache to avoid roundtrips to
system layout engine where possible. This makes it so that we might end
up not needing an owned version of text to insert into the cache, as we
might get a cached version.

The API boundary of line layout accepted text to be laid out as &str. It
then performed cache lookup (which didn't require having an owned
version) and only resorted to making an owned version when needed. As it
turned out though, exact cache hits are quite rare and we end up needing
owned version more often than not. The callers of line layout either
dealt with SharedStrings or owned Strings. Due to coercing them into
&str, we were ~always copying text into a new string (unless there was a
same-frame-hit). This is a bit wasteful, thus this PR generifies the API
a bit to make it easier to reuse existing string allocations if there
are any.

Benchmark scenario: scrolling down page-by-page through editor_tests (I
ran the same scenario twice):

![1](https://github.com/user-attachments/assets/8cd09692-2699-41d9-b211-83554d93902f)

![2](https://github.com/user-attachments/assets/d11f7c22-2315-4261-8189-2356baf5d2f7)


Release Notes:

- N/A
2025-01-02 11:06:01 +00:00
..
font_fallbacks.rs chore: Fix several style lints (#17488) 2024-09-06 11:58:39 +02:00
font_features.rs Disable ligatures in SSH connection dialogue (#20549) 2024-11-12 11:33:22 -07:00
line.rs Don't render invisibles with elements (#20841) 2024-11-18 16:47:25 -07:00
line_layout.rs gpui/perf: Use SharedString on API boundary of line layout (#22566) 2025-01-02 11:06:01 +00:00
line_wrapper.rs Fix line truncate crash on Windows (#17271) 2024-11-20 16:47:55 -08:00