summaryrefslogtreecommitdiff
path: root/LibCore
diff options
context:
space:
mode:
authorAndreas Kling <ankl@hms.se>2019-06-05 01:57:28 -0700
committerAndreas Kling <ankl@hms.se>2019-06-05 01:57:28 -0700
commit800242ed4e45021ca3a6b60d3ec0c072a41ca104 (patch)
tree6e27cbb441d6e51f7772672e48220bc3503e2644 /LibCore
parent848044b74c8e31f810ac9af4623f0bf0b75b5c8a (diff)
downloadserenity-800242ed4e45021ca3a6b60d3ec0c072a41ca104.zip
CEventLoop: Don't bother looking through fds when select() returns 0.
If it returns 0 that just means we hit the timeout. I suppose we could skip the timer checks if there are a non-zero number of fds marked as well, but I'm not sure that's a great idea since it will add some latency.
Diffstat (limited to 'LibCore')
-rw-r--r--LibCore/CEventLoop.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/LibCore/CEventLoop.cpp b/LibCore/CEventLoop.cpp
index d84a45fe16..3fca8b9239 100644
--- a/LibCore/CEventLoop.cpp
+++ b/LibCore/CEventLoop.cpp
@@ -199,8 +199,8 @@ void CEventLoop::wait_for_event(WaitMode mode)
should_wait_forever = false;
}
- int rc = select(max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
- if (rc < 0) {
+ int marked_fd_count = select(max_fd + 1, &rfds, &wfds, nullptr, should_wait_forever ? nullptr : &timeout);
+ if (marked_fd_count < 0) {
ASSERT_NOT_REACHED();
}
@@ -224,6 +224,9 @@ void CEventLoop::wait_for_event(WaitMode mode)
}
}
+ if (!marked_fd_count)
+ return;
+
for (auto& notifier : *s_notifiers) {
if (FD_ISSET(notifier->fd(), &rfds)) {
if (notifier->on_ready_to_read)