Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use extend instead of pushing in a loop #10453

Merged
merged 1 commit into from
Mar 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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))
}

Expand Down