From 7e0bb181521d5c1cf91f80c90d5bdb12f045acae Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sun, 17 Oct 2021 20:56:37 +0200 Subject: [PATCH] More #[inline] --- egui/src/util/history.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/egui/src/util/history.rs b/egui/src/util/history.rs index f16592ad..0f2daf9f 100644 --- a/egui/src/util/history.rs +++ b/egui/src/util/history.rs @@ -61,25 +61,30 @@ where } } + #[inline] pub fn max_len(&self) -> usize { self.max_len } + #[inline] pub fn max_age(&self) -> f32 { self.max_age } + #[inline] pub fn is_empty(&self) -> bool { self.values.is_empty() } /// Current number of values kept in history + #[inline] pub fn len(&self) -> usize { self.values.len() } /// Total number of values seen. /// Includes those that have been discarded due to `max_len` or `max_age`. + #[inline] pub fn total_count(&self) -> u64 { self.total_count } @@ -112,6 +117,7 @@ where self.values.iter().map(|(_time, value)| *value) } + #[inline] pub fn clear(&mut self) { self.values.clear() } @@ -145,7 +151,7 @@ where self.mean_time_interval().map(|time| 1.0 / time) } - /// Remove samples that are too old + /// Remove samples that are too old. pub fn flush(&mut self, now: f64) { while self.values.len() > self.max_len { self.values.pop_front(); @@ -170,6 +176,7 @@ where T: std::iter::Sum, T: std::ops::Div, { + #[inline] pub fn sum(&self) -> T { self.values().sum() } @@ -205,7 +212,8 @@ where T: std::ops::Sub, Vel: std::ops::Div, { - /// Calculate a smooth velocity (per second) over the entire time span + /// Calculate a smooth velocity (per second) over the entire time span. + /// Calculated as the last value minus the first value over the elapsed time between them. pub fn velocity(&self) -> Option { if let (Some(first), Some(last)) = (self.values.front(), self.values.back()) { let dt = (last.0 - first.0) as f32;