Files
zed/crates/language
Parker Loflin 021c7d4c4f language: Split buffer operations in linear time (#67014)
## Summary

`split_operations` took each 100-operation chunk with `Vec::drain(..n)`,
which shifts every remaining operation, so splitting was quadratic in
the number of operations. This iterates the operations once. The chunks
are unchanged, including the trailing empty chunk that
`create_buffer_for_peer` sends as the last one.

`create_buffer_for_peer` splits a buffer's full operation history when a
guest or remote client opens the buffer. Reconnecting projects and
channel buffers split the operations the other side is missing.

Time to split one list of edit operations, outside Zed in a release
build:

| Operations | Before | After |
|---|---|---|
| 10,000 | 192 µs | 12 µs |
| 100,000 | 25.8 ms | 123 µs |
| 250,000 | 171 ms | 502 µs |

## Testing

- `cargo test -p language --lib` passes.
- `cargo test -p remote_server --lib` passes.
- The collab `integration_tests`, `channel_buffer_tests` and
`remote_editing_collaboration_tests` pass.
- `./script/clippy -p language` 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
2026-11-15 22:49:03 +00:00
..