Skip to content

Commit db8f2f0

Browse files
committed
Simplify short summary generation
1 parent 0ba4262 commit db8f2f0

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

site/src/github.rs

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -604,8 +604,8 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
604604
return format!("This benchmark run did not return any relevant results.\n\n{footer}");
605605
}
606606

607-
let (primary_short_summary, primary_direction) = generate_short_summary(&primary);
608-
let (secondary_short_summary, secondary_direction) = generate_short_summary(&secondary);
607+
let primary_short_summary = generate_short_summary(&primary);
608+
let secondary_short_summary = generate_short_summary(&secondary);
609609

610610
let mut summary = format!(
611611
r#"
@@ -619,7 +619,7 @@ async fn summarize_run(ctxt: &SiteCtxt, commit: QueuedCommit, is_master_commit:
619619

620620
write!(summary, "\n{footer}").unwrap();
621621

622-
let direction = primary_direction.or(secondary_direction);
622+
let direction = primary.direction().or(secondary.direction());
623623
let next_steps = next_steps(primary, secondary, direction, is_master_commit);
624624

625625
format!(
@@ -705,7 +705,7 @@ compiler perf.{next_steps}
705705
)
706706
}
707707

708-
fn generate_short_summary(summary: &ComparisonSummary) -> (String, Option<Direction>) {
708+
fn generate_short_summary(summary: &ComparisonSummary) -> String {
709709
// Add an "s" to a word unless there's only one.
710710
fn ending(word: &'static str, count: usize) -> std::borrow::Cow<'static, str> {
711711
if count == 1 {
@@ -714,25 +714,20 @@ fn generate_short_summary(summary: &ComparisonSummary) -> (String, Option<Direct
714714
format!("{}s", word).into()
715715
}
716716

717-
if summary.is_relevant() {
718-
let direction = summary.direction().unwrap();
719-
let num_improvements = summary.number_of_improvements();
720-
let num_regressions = summary.number_of_regressions();
717+
let num_improvements = summary.number_of_improvements();
718+
let num_regressions = summary.number_of_regressions();
721719

722-
let text = match direction {
723-
Direction::Improvement => format!(
724-
"🎉 relevant {} found",
725-
ending("improvement", num_improvements)
726-
),
727-
Direction::Regression => format!(
728-
"😿 relevant {} found",
729-
ending("regression", num_regressions)
730-
),
731-
Direction::Mixed => "mixed results".to_string(),
732-
};
733-
(text, Some(direction))
734-
} else {
735-
("no relevant changes found".to_string(), None)
720+
match summary.direction() {
721+
Some(Direction::Improvement) => format!(
722+
"🎉 relevant {} found",
723+
ending("improvement", num_improvements)
724+
),
725+
Some(Direction::Regression) => format!(
726+
"😿 relevant {} found",
727+
ending("regression", num_regressions)
728+
),
729+
Some(Direction::Mixed) => "mixed results".to_string(),
730+
None => "no relevant changes found".to_string(),
736731
}
737732
}
738733

0 commit comments

Comments
 (0)