Repository: alacritty/alacritty
File: alacritty/src/event.rs (Rust)

Code before:
                // Process all pending events.
                WinitEvent::RedrawEventsCleared => {
                    // Check for pending frame callbacks on Wayland.
                    #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
                    if let Some(wayland_event_queue) = self.wayland_event_queue.as_mut() {
                        wayland_event_queue
                            .dispatch_pending(&mut (), |_, _, _| {})
                            .expect("failed to dispatch wayland event queue");
                    }

                    // Dispatch event to all windows.
                    for window_context in self.windows.values_mut() {
                        window_context.handle_event(
                            event_loop,
                            &proxy,
                            &mut clipboard,
                            &mut scheduler,
                            WinitEvent::RedrawEventsCleared,
                        );
                    }

                    // Update the scheduler after we've done everything, so
                    // the deadline will be more correct.
                    *control_flow = match scheduler.update() {
                        Some(instant) => ControlFlow::WaitUntil(instant),
                        None => ControlFlow::Wait,
                    };
                },
                // Process config update.
                WinitEvent::UserEvent(Event { payload: EventType::ConfigReload(path), .. }) => {
                    // Clear config logs from message bar for all terminals.
                    for window_context in self.windows.values_mut() {
                        if !window_context.message_buffer.is_empty() {
                            window_context.message_buffer.remove_target(LOG_TARGET_CONFIG);
                            window_context.display.pending_update.dirty = true;
                        }
                    }

                    // Load config and update each terminal.
                    if let Ok(config) = config::reload(&path, &self.cli_options) {
                        self.config = Rc::new(config);

                        for window_context in self.windows.values_mut() {
                            window_context.update_config(self.config.clone());
                        }
                    }
                },
                // Process IPC config update.
                #[cfg(unix)]
                WinitEvent::UserEvent(Event {
                    payload: EventType::IpcConfig(ipc_config),

Review comment (suggestion):
This comment is useful for my review, but "more correct" as a relative term will be completely useless when you don't have the comparison to the old version anymore.

I'd suggest rewording to something like this:

```suggestion
                    // Update the scheduler after event processing, to ensure the event loop deadline is as accurate as possible.
                    *control_flow = match scheduler.update() {
                        Some(instant) => ControlFlow::WaitUntil(instant),
                        None => ControlFlow::Wait,
                    };
```

Code after:
                WinitEvent::RedrawEventsCleared => {
                    // Check for pending frame callbacks on Wayland.
                    #[cfg(all(feature = "wayland", not(any(target_os = "macos", windows))))]
                    if let Some(wayland_event_queue) = self.wayland_event_queue.as_mut() {
                        wayland_event_queue
                            .dispatch_pending(&mut (), |_, _, _| {})
                            .expect("failed to dispatch wayland event queue");
                    }

                    // Dispatch event to all windows.
                    for window_context in self.windows.values_mut() {
                        window_context.handle_event(
                            event_loop,
                            &proxy,
                            &mut clipboard,
                            &mut scheduler,
                            WinitEvent::RedrawEventsCleared,
                        );
                    }

                    // Update the scheduler after event processing to ensure
                    // the event loop deadline is as accurate as possible.
                    *control_flow = match scheduler.update() {
                        Some(instant) => ControlFlow::WaitUntil(instant),
                        None => ControlFlow::Wait,
                    };
                },
                // Process config update.
                WinitEvent::UserEvent(Event { payload: EventType::ConfigReload(path), .. }) => {
                    // Clear config logs from message bar for all terminals.
                    for window_context in self.windows.values_mut() {
                        if !window_context.message_buffer.is_empty() {
                            window_context.message_buffer.remove_target(LOG_TARGET_CONFIG);
                            window_context.display.pending_update.dirty = true;
                        }
                    }

                    // Load config and update each terminal.
                    if let Ok(config) = config::reload(&path, &self.cli_options) {
                        self.config = Rc::new(config);

                        for window_context in self.windows.values_mut() {
                            window_context.update_config(self.config.clone());
                        }
                    }
                },
                // Process IPC config update.
                #[cfg(unix)]
                WinitEvent::UserEvent(Event {
                    payload: EventType::IpcConfig(ipc_config),
                    window_id,