input: Stop copying the value into InputPresentation (#2785)
## Description The presentation layer split regressed a bit in memory usage, because the value being a `String`. So each `state.presentation(cx)` would copy the entire document, three times per render. Rather than making that copy cheaper, the value is now gone from the snapshot. `InputPresentation` is rebuilt on every frame, and the state already owns the only `Rope` and hands it out through `InputBaseState::text`, so the render path borrows it directly. `InputPresentation` is read-only styling data again, as its doc says. Neither of the two places that read the value needs the text itself: - the accessibility value stays behind the `is_a11y_active()` gate, and materializes a string only when a client is listening - the clear button only needs the length `selected_text` is now public, so the selection has a borrowed counterpart to `selected_value`. The docs on both pairs point at each other: `value` / `selected_value` hand out an owned string, `text` / `selected_text` borrow the rope. ## How to Test I used the alloc bench from https://github.com/longbridge/gpui-component/pull/2783 and measured it on the test.rs fixture repeated 20 times, after 50 draws: | | draw bytes | draw blocks | |-------------------------|-------------|-------------| | main | 306,206,908 | 31,844 | | input-presentation-copy | 11,413,308 | 29,444 | These numbers were measured on the `Rope` version of the snapshot. Dropping the field removes the remaining clone as well. ## Breaking Changes `InputPresentation::value` is removed. Read the text from the state instead. ```diff - let value = presentation.value(); + let value = state.read(cx).text(); ``` ## Checklist - [x] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document and followed the guidelines. - [x] Reviewed the changes in this PR and confirmed AI generated code (If any) is accurate. - [x] Passed `cargo run` for story tests related to the changes. - [ ] Tested macOS, Windows and Linux platforms performance (if the change is platform-specific) --------- Co-authored-by: Jason Lee <huacnlee@gmail.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
A
Andreas Johansson committed
f478ff6bd2af3676f8491e6c9280f598439df053
Parent: 270cf3c
Committed by GitHub <noreply@github.com>
on 8/20/2026, 10:56:46 AM