Skip to content

Commit 9923e81

Browse files
perf: Avoid unnecessary clones when retrieving crate docs from the cache
1 parent 253d080 commit 9923e81

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

compiler/pavexc/src/rustdoc/queries.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ impl CrateCollection {
168168
{
169169
fn get_if_cached(
170170
package_id: PackageId,
171-
package_graph: PackageGraph,
172-
cache: RustdocGlobalFsCache,
171+
package_graph: &PackageGraph,
172+
cache: &RustdocGlobalFsCache,
173173
diagnostic_sink: &DiagnosticSink,
174174
) -> (PackageId, Option<Crate>) {
175175
let cache_key = RustdocCacheKey::new(&package_id, &package_graph);
@@ -198,14 +198,12 @@ impl CrateCollection {
198198

199199
// It can take a while to deserialize the JSON docs for a crate from the cache,
200200
// so we parallelize the operation.
201-
let package_graph = self.package_graph.clone();
202-
let cache = self.disk_cache.clone();
203-
let sink = self.diagnostic_sink.clone();
201+
let package_graph = &self.package_graph;
202+
let cache = &self.disk_cache;
203+
let sink = &self.diagnostic_sink;
204204
let tracing_span = Span::current();
205-
let map_op = move |id| {
206-
tracing_span
207-
.in_scope(|| get_if_cached(id, package_graph.clone(), cache.clone(), &sink.clone()))
208-
};
205+
let map_op =
206+
move |id| tracing_span.in_scope(|| get_if_cached(id, &package_graph, cache, &sink));
209207

210208
let mut to_be_computed = vec![];
211209

0 commit comments

Comments
 (0)