Skip to content

Commit 9cffcfc

Browse files
committed
Auto merge of #10453 - notriddle:notriddle/vec-extend, r=weihanglo
Use `extend` instead of `push`ing in a loop
2 parents 72873d8 + d8c0822 commit 9cffcfc

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/cargo/core/compiler/fingerprint.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1568,13 +1568,14 @@ fn local_fingerprints_deps(
15681568
local.push(LocalFingerprint::RerunIfChanged { output, paths });
15691569
}
15701570

1571-
for var in deps.rerun_if_env_changed.iter() {
1572-
let val = env::var(var).ok();
1573-
local.push(LocalFingerprint::RerunIfEnvChanged {
1574-
var: var.clone(),
1575-
val,
1576-
});
1577-
}
1571+
local.extend(
1572+
deps.rerun_if_env_changed
1573+
.iter()
1574+
.map(|var| LocalFingerprint::RerunIfEnvChanged {
1575+
var: var.clone(),
1576+
val: env::var(var).ok(),
1577+
}),
1578+
);
15781579

15791580
local
15801581
}
@@ -1697,14 +1698,13 @@ pub fn parse_dep_info(
16971698
};
16981699
let mut ret = RustcDepInfo::default();
16991700
ret.env = info.env;
1700-
for (ty, path) in info.files {
1701-
let path = match ty {
1701+
ret.files.extend(info.files.into_iter().map(|(ty, path)| {
1702+
match ty {
17021703
DepInfoPathType::PackageRootRelative => pkg_root.join(path),
17031704
// N.B. path might be absolute here in which case the join will have no effect
17041705
DepInfoPathType::TargetRootRelative => target_root.join(path),
1705-
};
1706-
ret.files.push(path);
1707-
}
1706+
}
1707+
}));
17081708
Ok(Some(ret))
17091709
}
17101710

0 commit comments

Comments
 (0)