mirror of
https://github.com/zed-industries/zed.git
synced 2026-11-20 15:40:29 +01:00
fb62376caa
## Summary `get_buffer_content_or_outline` chooses between a file's full text and its outline by size. It measured the size with `buffer.text().len()`, which copies the whole buffer into a `String`. `buffer.len()` reads the same length from the rope's summary. This runs on the main thread when the read file tool reads a file without a line range and when a file is mentioned as context. Both expressions timed on a `text::Buffer` in a release build: | Buffer size | `text().len()` | `len()` | |---|---|---| | 16 KB | 1.8 µs | < 0.1 µs | | 256 KB | 25 µs | < 0.1 µs | | 4 MB | 398 µs | < 0.1 µs | | 64 MB | 22 ms | < 0.1 µs | ## Testing `cargo test -p agent --lib outline` 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