1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-03 07:10:04 -04:00

now using a HashMap insted of a Vec to store repaint_after

This commit is contained in:
Konkitoman
2023-09-26 20:18:50 +03:00
parent 5c8c56c1b8
commit f3686e2459
2 changed files with 5 additions and 6 deletions

View File

@@ -136,7 +136,7 @@ impl Repaint {
&mut self, &mut self,
viewport_id: ViewportId, viewport_id: ViewportId,
viewports: &[ViewportId], viewports: &[ViewportId],
) -> Vec<(ViewportId, std::time::Duration)> { ) -> HashMap<ViewportId, std::time::Duration> {
// if repaint_requests is greater than zero. just set the duration to zero for immediate // 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. // repaint. if there's no repaint requests, then we can use the actual repaint_after instead.
let repaint_after = if self let repaint_after = if self
@@ -166,10 +166,7 @@ impl Repaint {
self.repaint_requests self.repaint_requests
.retain(|id, repaints| viewports.contains(id) && *repaints != 0); .retain(|id, repaints| viewports.contains(id) && *repaints != 0);
self.repaint_after self.repaint_after.clone()
.iter()
.map(|(id, time)| (*id, *time))
.collect()
} }
} }

View File

@@ -1,5 +1,7 @@
//! All the data egui returns to the backend at the end of each frame. //! All the data egui returns to the backend at the end of each frame.
use ahash::HashMap;
use crate::ViewportId; use crate::ViewportId;
use crate::{ViewportCommand, ViewportOutput, WidgetType}; 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, /// 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 /// 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. /// specified amount of time, and repaint egui without any new input.
pub repaint_after: Vec<(ViewportId, std::time::Duration)>, pub repaint_after: HashMap<ViewportId, std::time::Duration>,
/// Texture changes since last frame (including the font texture). /// Texture changes since last frame (including the font texture).
/// ///