remove reduntant histogram

This commit is contained in:
Robin Appelman 2025-08-09 17:27:25 +02:00
commit 4f9e5df792

View file

@ -55,8 +55,6 @@ impl<'logs> App<'logs> {
pub struct LogMatch<'logs> { pub struct LogMatch<'logs> {
pub result: Option<MatchResult>, pub result: Option<MatchResult>,
pub count: usize, pub count: usize,
pub histogram: OnceCell<TimeGraph>,
pub sparkline: OnceCell<SparkLine>,
pub all: LineSet<'logs>, pub all: LineSet<'logs>,
pub grouped: Vec<LineSet<'logs>>, pub grouped: Vec<LineSet<'logs>>,
} }
@ -70,28 +68,17 @@ impl<'logs> LogMatch<'logs> {
LogMatch { LogMatch {
result, result,
count, count,
histogram: OnceCell::new(),
sparkline: OnceCell::new(),
grouped, grouped,
all, all,
} }
} }
pub fn sparkline(&self, app: &App) -> &SparkLine { pub fn sparkline(&self, app: &App) -> &SparkLine {
self.sparkline self.all.sparkline(app)
.get_or_init(|| self.histogram(app).sparkline())
} }
pub fn histogram(&self, app: &App) -> &TimeGraph { pub fn histogram(&self, app: &App) -> &TimeGraph {
self.histogram.get_or_init(|| { self.all.histogram(app)
let min_time = app.lines.first().time;
let max_time = app.lines.last().time;
let mut histogram = TimeGraph::new(min_time, max_time);
for line in &self.all.lines {
histogram.add(line.time);
}
histogram
})
} }
pub fn row_count(&self) -> usize { pub fn row_count(&self) -> usize {