project search: Reduce clones and allocations (#31133)
Release Notes: - N/A
This commit is contained in:
parent
5f452dbca2
commit
dce22a965e
2 changed files with 17 additions and 18 deletions
|
@ -3662,9 +3662,8 @@ impl Project {
|
||||||
// ranges in the buffer matched by the query.
|
// ranges in the buffer matched by the query.
|
||||||
let mut chunks = pin!(chunks);
|
let mut chunks = pin!(chunks);
|
||||||
'outer: while let Some(matching_buffer_chunk) = chunks.next().await {
|
'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 {
|
for buffer in matching_buffer_chunk {
|
||||||
let buffer = buffer.clone();
|
|
||||||
let query = query.clone();
|
let query = query.clone();
|
||||||
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||||
chunk_results.push(cx.background_spawn(async move {
|
chunk_results.push(cx.background_spawn(async move {
|
||||||
|
|
|
@ -324,11 +324,9 @@ impl ProjectSearch {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let excerpts = project_search
|
let mut new_ranges = project_search
|
||||||
.update(cx, |project_search, _| project_search.excerpts.clone())
|
.update(cx, |project_search, cx| {
|
||||||
.ok()?;
|
project_search.excerpts.update(cx, |excerpts, cx| {
|
||||||
let mut new_ranges = excerpts
|
|
||||||
.update(cx, |excerpts, cx| {
|
|
||||||
buffers_with_ranges
|
buffers_with_ranges
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(buffer, ranges)| {
|
.map(|(buffer, ranges)| {
|
||||||
|
@ -341,7 +339,9 @@ impl ProjectSearch {
|
||||||
})
|
})
|
||||||
.collect::<FuturesOrdered<_>>()
|
.collect::<FuturesOrdered<_>>()
|
||||||
})
|
})
|
||||||
|
})
|
||||||
.ok()?;
|
.ok()?;
|
||||||
|
|
||||||
while let Some(new_ranges) = new_ranges.next().await {
|
while let Some(new_ranges) = new_ranges.next().await {
|
||||||
project_search
|
project_search
|
||||||
.update(cx, |project_search, _| {
|
.update(cx, |project_search, _| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue