mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
refactor: iterator instead of extra allocation for registering patches
This commit is contained in:
parent
a6230e348b
commit
178bde773b
@ -205,7 +205,7 @@ impl Resolve {
|
||||
self.graph.path_to_top(pkg)
|
||||
}
|
||||
|
||||
pub fn register_used_patches(&mut self, patches: &[Summary]) {
|
||||
pub fn register_used_patches<'a>(&mut self, patches: impl Iterator<Item = &'a Summary>) {
|
||||
for summary in patches {
|
||||
if !self.graph.contains(&summary.package_id()) {
|
||||
self.unused_patches.push(summary.package_id())
|
||||
|
@ -412,12 +412,9 @@ pub fn resolve_with_previous<'gctx>(
|
||||
ResolveVersion::with_rust_version(ws.rust_version()),
|
||||
Some(ws.gctx()),
|
||||
)?;
|
||||
let patches: Vec<_> = registry
|
||||
.patches()
|
||||
.values()
|
||||
.flat_map(|v| v.iter().cloned())
|
||||
.collect();
|
||||
resolved.register_used_patches(&patches[..]);
|
||||
|
||||
let patches = registry.patches().values().flat_map(|v| v.iter());
|
||||
resolved.register_used_patches(patches);
|
||||
|
||||
if register_patches && !resolved.unused_patches().is_empty() {
|
||||
emit_warnings_of_unused_patches(ws, &resolved, registry)?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user