mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 18:08:55 +03:00
Avoid unnecessary request_redraw() calls
This commit is contained in:
parent
78feb45d82
commit
cf91390e56
@ -193,15 +193,12 @@ pub fn run_event_loop(title: &str, state: roc::State) -> Result<(), Box<dyn Erro
|
||||
} => {
|
||||
keyboard_modifiers = modifiers;
|
||||
}
|
||||
Event::MainEventsCleared => window.request_redraw(),
|
||||
Event::RedrawRequested { .. } => {
|
||||
// If we shouldn't draw yet, keep waiting until we should.
|
||||
let current_time = Instant::now();
|
||||
|
||||
if next_render_time.saturating_duration_since(current_time) > TIME_BETWEEN_RENDERS {
|
||||
// Keep waiting until it's time to draw again.
|
||||
window.request_redraw();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user