refactor: change event_create() to a macro (#26343)

A varargs functions can never be inlined, so a macro is faster.
This commit is contained in:
zeertzjq
2023-12-01 15:22:22 +08:00
committed by GitHub
parent 130cb4815a
commit 548f03c66c
19 changed files with 49 additions and 75 deletions

View File

@@ -404,7 +404,7 @@ static void handle_request(Channel *channel, Unpacker *p, Array args)
if (is_get_mode && !input_blocking()) {
// Defer the event to a special queue used by os/input.c. #6247
multiqueue_put(ch_before_blocking_events, request_event, 1, evdata);
multiqueue_put(ch_before_blocking_events, request_event, evdata);
} else {
// Invoke immediately.
request_event((void **)&evdata);
@@ -412,12 +412,11 @@ static void handle_request(Channel *channel, Unpacker *p, Array args)
} else {
bool is_resize = p->handler.fn == handle_nvim_ui_try_resize;
if (is_resize) {
Event ev = event_create_oneshot(event_create(request_event, 1, evdata),
2);
Event ev = event_create_oneshot(event_create(request_event, evdata), 2);
multiqueue_put_event(channel->events, ev);
multiqueue_put_event(resize_events, ev);
} else {
multiqueue_put(channel->events, request_event, 1, evdata);
multiqueue_put(channel->events, request_event, evdata);
DLOG("RPC: scheduled %.*s", (int)p->method_name_len, p->handler.name);
}
}
@@ -484,7 +483,7 @@ static bool channel_write(Channel *channel, WBuffer *buffer)
if (channel->streamtype == kChannelStreamInternal) {
channel_incref(channel);
CREATE_EVENT(channel->events, internal_read_event, 2, channel, buffer);
CREATE_EVENT(channel->events, internal_read_event, channel, buffer);
success = true;
} else {
Stream *in = channel_instream(channel);