diff options
author | bptato <nincsnevem662@gmail.com> | 2024-09-03 01:17:53 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-09-03 01:22:00 +0200 |
commit | 298684d174be90be57967f15c2f1bf0d24ba2446 (patch) | |
tree | f4cbd02fecb39b39f931bceb1b79dbc439223d0f /src/local/client.nim | |
parent | 6d8c2fca2e39cc9f3cc9a99cac5584864eaa0ed4 (diff) | |
download | chawan-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.nim | 10 |
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: |