From d8c08223fcb375a7cd366e10bfc53f14961fe2fc Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Thu, 3 Mar 2022 16:02:13 -0700 Subject: [PATCH] Use `extend` instead of `push`ing in a loop --- src/cargo/core/compiler/fingerprint.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index e3aaf9c76ec..be8d060c73e 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -1568,13 +1568,14 @@ fn local_fingerprints_deps( local.push(LocalFingerprint::RerunIfChanged { output, paths }); } - for var in deps.rerun_if_env_changed.iter() { - let val = env::var(var).ok(); - local.push(LocalFingerprint::RerunIfEnvChanged { - var: var.clone(), - val, - }); - } + local.extend( + deps.rerun_if_env_changed + .iter() + .map(|var| LocalFingerprint::RerunIfEnvChanged { + var: var.clone(), + val: env::var(var).ok(), + }), + ); local } @@ -1697,14 +1698,13 @@ pub fn parse_dep_info( }; let mut ret = RustcDepInfo::default(); ret.env = info.env; - for (ty, path) in info.files { - let path = match ty { + ret.files.extend(info.files.into_iter().map(|(ty, path)| { + match ty { DepInfoPathType::PackageRootRelative => pkg_root.join(path), // N.B. path might be absolute here in which case the join will have no effect DepInfoPathType::TargetRootRelative => target_root.join(path), - }; - ret.files.push(path); - } + } + })); Ok(Some(ret)) }