From f3686e245915089d1f2656847a70b788ad06d007 Mon Sep 17 00:00:00 2001 From: Konkitoman Date: Tue, 26 Sep 2023 20:18:50 +0300 Subject: [PATCH] now using a HashMap insted of a Vec to store repaint_after --- crates/egui/src/context.rs | 7 ++----- crates/egui/src/data/output.rs | 4 +++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 6df1a514e..7ad5a65ec 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -136,7 +136,7 @@ impl Repaint { &mut self, viewport_id: ViewportId, viewports: &[ViewportId], - ) -> Vec<(ViewportId, std::time::Duration)> { + ) -> HashMap { // if repaint_requests is greater than zero. just set the duration to zero for immediate // repaint. if there's no repaint requests, then we can use the actual repaint_after instead. let repaint_after = if self @@ -166,10 +166,7 @@ impl Repaint { self.repaint_requests .retain(|id, repaints| viewports.contains(id) && *repaints != 0); - self.repaint_after - .iter() - .map(|(id, time)| (*id, *time)) - .collect() + self.repaint_after.clone() } } diff --git a/crates/egui/src/data/output.rs b/crates/egui/src/data/output.rs index 6e4d159df..9c2f0d770 100644 --- a/crates/egui/src/data/output.rs +++ b/crates/egui/src/data/output.rs @@ -1,5 +1,7 @@ //! All the data egui returns to the backend at the end of each frame. +use ahash::HashMap; + use crate::ViewportId; use crate::{ViewportCommand, ViewportOutput, WidgetType}; @@ -19,7 +21,7 @@ pub struct FullOutput { /// duration elapses. when in reactive mode, egui spends forever waiting for input and only then, /// will it repaint itself. this can be used to make sure that backend will only wait for a /// specified amount of time, and repaint egui without any new input. - pub repaint_after: Vec<(ViewportId, std::time::Duration)>, + pub repaint_after: HashMap, /// Texture changes since last frame (including the font texture). ///