editor: Reduce allocations during editor prepaint - #61290
Merged
ChristopherBiscardi merged 6 commits intoJul 20, 2026
Conversation
Our `.all()` only requires the current element for evaluation, meaning we don't need to store all elements at once, and can get rid of the whole Vec
These instances are turned into iterators right away, so we don't need to allocate them on the heap first. The elements are all small, meaning stack space isnt an issue.
`is_none() { return None }` is a bad pattern, use ? instead. Saves the
`is_some_and` later.
Calling the right constructor prevents for example turning a `Arc<str>` into a `&str` and then allocating a new buffer for it, when we could just reuse the owned `Arc` for free
`x_and_width` unnecessarily returned a Option, because we stored it directly into a variable in a larger scope, store it first locally which lets us get rid of a unwrap
Using iterators here allows us to know the size of the `Vec` that will be allocated beforehand, allowing O(1) allocation instead of ammortized O(1).
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
Found some unnecessary allocations and an `.unwrap()` while working on a separate issue. The PR makes no behavior changes and should be trivial to review. ## Testing All tests pass. These changes are not expected to change any behavior. None of the changes are interleaving, so it should be easy to review top-down. Reasoning for each change can be read from individual commit messages. Release Notes: - N/A or Added/Fixed/Improved ...
playdohface
pushed a commit
to playdohface/zed
that referenced
this pull request
Aug 29, 2026
Found some unnecessary allocations and an `.unwrap()` while working on a separate issue. The PR makes no behavior changes and should be trivial to review. ## Testing All tests pass. These changes are not expected to change any behavior. None of the changes are interleaving, so it should be easy to review top-down. Reasoning for each change can be read from individual commit messages. Release Notes: - N/A or Added/Fixed/Improved ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found some unnecessary allocations and an
.unwrap()while working on a separate issue. The PR makes no behavior changes and should be trivial to review.Testing
All tests pass. These changes are not expected to change any behavior.
None of the changes are interleaving, so it should be easy to review top-down. Reasoning for each change can be read from individual commit messages.
Release Notes: