indexed_docs: Remove some unnecessary cloning (#30236)

Other small patch to reduce allocations.

`.iter().cloned().collect()` calls `Clone` per element, whereas
`.into_iter().collect()` preallocates the `Vec`.

The Zed repo for example has up to 1700 packages on some build
configurations, meaning this change theoretically saves up to 1699
allocations. It's likely the compiler has already optimized this away,
but it's good to be explicit.

Release Notes:

- N/A
This commit is contained in:
tidely 2025-05-08 12:59:56 +02:00 committed by GitHub
parent a61958e886
commit 4b5158b168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -79,7 +79,7 @@ impl IndexedDocsProvider for LocalRustdocProvider {
*WORKSPACE_CRATES.write() = Some((workspace_crates.clone(), Instant::now()));
Ok(workspace_crates.iter().cloned().collect())
Ok(workspace_crates.into_iter().collect())
}
async fn index(&self, package: PackageName, database: Arc<IndexedDocsDatabase>) -> Result<()> {