Files
Anthony Eid 415d310e52 gpui: Avoid copying and comparing the bytes of shared text (#66728)
Two small changes that avoid touching the bytes of text that hasn't
changed:

- `SharedString` equality checks whether both sides point at the same
bytes before comparing them. `SmolStr` compares heap-allocated and
static strings byte by byte even when both are clones of the same
allocation, which is common when a view clones the same label into its
elements every frame. Strings of up to 23 bytes are stored inline and
still use `SmolStr`'s comparison. `Hash` is now implemented by hand
(clippy rejects deriving it alongside a manual `PartialEq`) and hashes
exactly as before.
- A `&'static str` text child (e.g. `div().child("Some label")`) is
wrapped with `SharedString::new_static` instead of copied every frame,
which allocated for strings longer than 23 bytes. Its comparisons now
hit the pointer check above.

Release Notes:

- N/A
- [GPUI] Avoid allocating for a SharedString in `imp Element for
&'static str`
2026-11-10 23:00:03 +00:00
..