Skip to content

Commit 178bde7

Browse files
committed
refactor: iterator instead of extra allocation for registering patches
1 parent a6230e3 commit 178bde7

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/cargo/core/resolver/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ impl Resolve {
205205
self.graph.path_to_top(pkg)
206206
}
207207

208-
pub fn register_used_patches(&mut self, patches: &[Summary]) {
208+
pub fn register_used_patches<'a>(&mut self, patches: impl Iterator<Item = &'a Summary>) {
209209
for summary in patches {
210210
if !self.graph.contains(&summary.package_id()) {
211211
self.unused_patches.push(summary.package_id())

src/cargo/ops/resolve.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,9 @@ pub fn resolve_with_previous<'gctx>(
412412
ResolveVersion::with_rust_version(ws.rust_version()),
413413
Some(ws.gctx()),
414414
)?;
415-
let patches: Vec<_> = registry
416-
.patches()
417-
.values()
418-
.flat_map(|v| v.iter().cloned())
419-
.collect();
420-
resolved.register_used_patches(&patches[..]);
415+
416+
let patches = registry.patches().values().flat_map(|v| v.iter());
417+
resolved.register_used_patches(patches);
421418

422419
if register_patches && !resolved.unused_patches().is_empty() {
423420
emit_warnings_of_unused_patches(ws, &resolved, registry)?;

0 commit comments

Comments
 (0)