Auto merge of #10453 - notriddle:notriddle/vec-extend, r=weihanglo

Use `extend` instead of `push`ing in a loop
This commit is contained in:
bors 2022-03-04 01:27:18 +00:00
commit 9cffcfc91e

View File

@ -1568,13 +1568,14 @@ fn local_fingerprints_deps(
local.push(LocalFingerprint::RerunIfChanged { output, paths }); local.push(LocalFingerprint::RerunIfChanged { output, paths });
} }
for var in deps.rerun_if_env_changed.iter() { local.extend(
let val = env::var(var).ok(); deps.rerun_if_env_changed
local.push(LocalFingerprint::RerunIfEnvChanged { .iter()
var: var.clone(), .map(|var| LocalFingerprint::RerunIfEnvChanged {
val, var: var.clone(),
}); val: env::var(var).ok(),
} }),
);
local local
} }
@ -1697,14 +1698,13 @@ pub fn parse_dep_info(
}; };
let mut ret = RustcDepInfo::default(); let mut ret = RustcDepInfo::default();
ret.env = info.env; ret.env = info.env;
for (ty, path) in info.files { ret.files.extend(info.files.into_iter().map(|(ty, path)| {
let path = match ty { match ty {
DepInfoPathType::PackageRootRelative => pkg_root.join(path), DepInfoPathType::PackageRootRelative => pkg_root.join(path),
// N.B. path might be absolute here in which case the join will have no effect // N.B. path might be absolute here in which case the join will have no effect
DepInfoPathType::TargetRootRelative => target_root.join(path), DepInfoPathType::TargetRootRelative => target_root.join(path),
}; }
ret.files.push(path); }));
}
Ok(Some(ret)) Ok(Some(ret))
} }