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

@ -324,24 +324,24 @@ impl ProjectSearch {
}
}
let excerpts = project_search
.update(cx, |project_search, _| project_search.excerpts.clone())
.ok()?;
let mut new_ranges = excerpts
.update(cx, |excerpts, cx| {
buffers_with_ranges
.into_iter()
.map(|(buffer, ranges)| {
excerpts.set_anchored_excerpts_for_path(
buffer,
ranges,
editor::DEFAULT_MULTIBUFFER_CONTEXT,
cx,
)
})
.collect::<FuturesOrdered<_>>()
let mut new_ranges = project_search
.update(cx, |project_search, cx| {
project_search.excerpts.update(cx, |excerpts, cx| {
buffers_with_ranges
.into_iter()
.map(|(buffer, ranges)| {
excerpts.set_anchored_excerpts_for_path(
buffer,
ranges,
editor::DEFAULT_MULTIBUFFER_CONTEXT,
cx,
)
})
.collect::<FuturesOrdered<_>>()
})
})
.ok()?;
while let Some(new_ranges) = new_ranges.next().await {
project_search
.update(cx, |project_search, _| {