about summary refs log tree commit diff stats
path: root/src/local/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-09-03 01:17:53 +0200
committerbptato <nincsnevem662@gmail.com>2024-09-03 01:22:00 +0200
commit298684d174be90be57967f15c2f1bf0d24ba2446 (patch)
treef4cbd02fecb39b39f931bceb1b79dbc439223d0f /src/local/client.nim
parent6d8c2fca2e39cc9f3cc9a99cac5584864eaa0ed4 (diff)
downloadchawan-298684d174be90be57967f15c2f1bf0d24ba2446.tar.gz
loader, client, buffer: use selectInto (not select)
select allocates. (makes sense, but I never realized...)
Diffstat (limited to 'src/local/client.nim')
-rw-r--r--src/local/client.nim10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/local/client.nim b/src/local/client.nim
index 3d3e1bb0..02f497ff 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -545,9 +545,10 @@ proc inputLoop(client: Client) =
   selector.registerHandle(int(client.pager.term.istream.fd), {Read}, 0)
   when not defined(android):
     let sigwinch = selector.registerSignal(int(SIGWINCH), 0)
+  var keys: array[64, ReadyKey]
   while true:
-    let events = client.selector.select(-1)
-    for event in events:
+    let count = client.selector.selectInto(-1, keys)
+    for event in keys.toOpenArray(0, count - 1):
       if Read in event.events:
         client.handleRead(event.fd)
       if Write in event.events:
@@ -598,9 +599,10 @@ func hasSelectFds(client: Client): bool =
     client.pager.procmap.len > 0
 
 proc headlessLoop(client: Client) =
+  var keys: array[64, ReadyKey]
   while client.hasSelectFds():
-    let events = client.selector.select(-1)
-    for event in events:
+    let count = client.selector.selectInto(-1, keys)
+    for event in keys.toOpenArray(0, count - 1):
       if Read in event.events:
         client.handleRead(event.fd)
       if Write in event.events: