project search: Reduce clones and allocations (#31133)

Release Notes:

- N/A
This commit is contained in:
Remco Smits 2025-05-22 04:11:00 +02:00 committed by GitHub
parent 5f452dbca2
commit dce22a965e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 18 deletions

View file

@ -3662,9 +3662,8 @@ impl Project {
// ranges in the buffer matched by the query.
let mut chunks = pin!(chunks);
'outer: while let Some(matching_buffer_chunk) = chunks.next().await {
let mut chunk_results = Vec::new();
let mut chunk_results = Vec::with_capacity(matching_buffer_chunk.len());
for buffer in matching_buffer_chunk {
let buffer = buffer.clone();
let query = query.clone();
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
chunk_results.push(cx.background_spawn(async move {