From ecdb375ce0996e0cb1a16c2e70c3c4750c090de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20M=C3=BCller?= Date: Mon, 25 Mar 2024 11:20:18 +0100 Subject: [PATCH] Fix `min_by?` in IOCP event loop `#run_once` `min_by` raises if the queue is empty but we want to handle this case explicitly in the following condition. --- src/crystal/system/win32/event_loop_iocp.cr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crystal/system/win32/event_loop_iocp.cr b/src/crystal/system/win32/event_loop_iocp.cr index 3889b8b25d81..ffae160c64eb 100644 --- a/src/crystal/system/win32/event_loop_iocp.cr +++ b/src/crystal/system/win32/event_loop_iocp.cr @@ -42,7 +42,7 @@ class Crystal::Iocp::EventLoop < Crystal::EventLoop # timeout for waiting on the completion port. # OPTIMIZE: Implement @queue as a priority queue in order to avoid this # explicit search for the lowest value and dequeue more efficient. - next_event = @queue.min_by(&.wake_at) + next_event = @queue.min_by?(&.wake_at) unless next_event Crystal::System.print_error "Warning: No runnables in scheduler. Exiting program.\n"