bootstrap: Avoid cloning change-id list · rust-lang/rust@ad29f94 (original) (raw)

3 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -182,7 +182,7 @@ fn check_version(config: &Config) -> Option {
182 182 }
183 183
184 184 msg.push_str("There have been changes to x.py since you last updated:\n");
185 - msg.push_str(&human_readable_changes(&changes));
185 + msg.push_str(&human_readable_changes(changes));
186 186
187 187 msg.push_str("NOTE: to silence this warning, ");
188 188 msg.push_str(&format!(
Original file line number Diff line number Diff line change
@@ -1358,7 +1358,7 @@ impl Config {
1358 1358 if !changes.is_empty() {
1359 1359 println!(
1360 1360 "WARNING: There have been changes to x.py since you last updated:\n{}",
1361 -crate::human_readable_changes(&changes)
1361 +crate::human_readable_changes(changes)
1362 1362 );
1363 1363 }
1364 1364 }
Original file line number Diff line number Diff line change
@@ -35,29 +35,25 @@ impl Display for ChangeSeverity {
35 35 }
36 36 }
37 37
38 -pub fn find_recent_config_change_ids(current_id: usize) -> Vec<ChangeInfo> {
39 -if !CONFIG_CHANGE_HISTORY.iter().any(|config
38 +pub fn find_recent_config_change_ids(current_id: usize) -> &'static [ChangeInfo] {
39 +if let Some(index) =
40 +CONFIG_CHANGE_HISTORY.iter().position(|config
41 +{
42 +// Skip the current_id and IDs before it
43 +&CONFIG_CHANGE_HISTORY[index + 1..]
44 +} else {
40 45 // If the current change-id is greater than the most recent one, return
41 46 // an empty list (it may be due to switching from a recent branch to an
42 47 // older one); otherwise, return the full list (assuming the user provided
43 48 // the incorrect change-id by accident).
44 49 if let Some(config) = CONFIG_CHANGE_HISTORY.iter().max_by_key(|config
45 50 if current_id > config.change_id {
46 -return Vec::new();
51 +return &[];
47 52 }
48 53 }
49 54
50 -return CONFIG_CHANGE_HISTORY.to_vec();
55 +CONFIG_CHANGE_HISTORY
51 56 }
52 -
53 -let index =
54 -CONFIG_CHANGE_HISTORY.iter().position(|config
55 -
56 -CONFIG_CHANGE_HISTORY
57 -.iter()
58 -.skip(index + 1) // Skip the current_id and IDs before it
59 -.cloned()
60 -.collect()
61 57 }
62 58
63 59 pub fn human_readable_changes(changes: &[ChangeInfo]) -> String {