mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-20 15:40:29 +01:00
62cb1ac7b1
## Summary `LineWithInvisibles::from_chunks` passed `line.clone().into()` to `shape_line` at each line break. That cloned the `String`, then copied it again into the `SharedString`. `line.as_str().into()` copies it once, as the other `shape_line` call in this function already does. The two expressions timed outside Zed in a release build, median per call including the drop: | Line length | `line.clone().into()` | `line.as_str().into()` | |---|---|---| | 16 bytes | 11 ns | 7 ns | | 40 bytes | 25 ns | 11 ns | | 80 bytes | 17 ns | 12 ns | | 120 bytes | 17 ns | 12 ns | | 400 bytes | 22 ns | 15 ns | That is 4 to 14 ns per row, about 1 µs per 100 rows laid out. Layout time in the editor was not measured. ## Testing `cargo test -p editor --lib element::tests` passes. ## Self-review - [x] I've reviewed my diff for quality, security, reliability, and performance. - [x] UI changes follow the [checklist](https://zed.dev/docs/development/ui-checklist). - [x] Tests cover the new or changed behavior. Release Notes: - N/A