Skip to content

Commit 9cc74c4

Browse files
authored
Merge pull request #114 from lzutao/premature
Some premature optimizations
2 parents 50e8e29 + 8024b05 commit 9cc74c4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/main.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,16 +1056,19 @@ fn bisect_nightlies(cfg: &Config, client: &Client) -> Result<BisectionResult, Er
10561056
fn toolchains_between(cfg: &Config, a: ToolchainSpec, b: ToolchainSpec) -> Vec<Toolchain> {
10571057
match (a, b) {
10581058
(ToolchainSpec::Nightly { date: a }, ToolchainSpec::Nightly { date: b }) => {
1059-
let mut toolchains = Vec::new();
1059+
let size = (b - a).num_days() + 1;
1060+
assert!(size > 0);
1061+
let mut toolchains = Vec::with_capacity(size as usize);
10601062
let mut date = a;
1063+
let mut std_targets = vec![cfg.args.host.clone(), cfg.target.clone()];
1064+
std_targets.sort();
1065+
std_targets.dedup();
10611066
while date <= b {
1062-
let mut t = Toolchain {
1067+
let t = Toolchain {
10631068
spec: ToolchainSpec::Nightly { date },
10641069
host: cfg.args.host.clone(),
1065-
std_targets: vec![cfg.args.host.clone(), cfg.target.clone()],
1070+
std_targets: std_targets.clone(),
10661071
};
1067-
t.std_targets.sort();
1068-
t.std_targets.dedup();
10691072
toolchains.push(t);
10701073
date = date.succ();
10711074
}

0 commit comments

Comments
 (0)