aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui_client.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-01-03 15:24:41 +0100
committerbfredl <bjorn.linse@gmail.com>2023-01-03 17:31:54 +0100
commitb2295ac4ec80e141628cea33ebee81c96e168989 (patch)
treeee197c75d19b1922d9a1149f8b5e1b7a12a76c70 /src/nvim/ui_client.c
parent5b22b32e50858b781eb2658ba099eaffaa5ea13b (diff)
downloadrneovim-b2295ac4ec80e141628cea33ebee81c96e168989.tar.gz
rneovim-b2295ac4ec80e141628cea33ebee81c96e168989.tar.bz2
rneovim-b2295ac4ec80e141628cea33ebee81c96e168989.zip
refactor(api): do not allocate temporaries for internal events
Diffstat (limited to 'src/nvim/ui_client.c')
-rw-r--r--src/nvim/ui_client.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c
index 6fc3a05e96..365a76de3f 100644
--- a/src/nvim/ui_client.c
+++ b/src/nvim/ui_client.c
@@ -56,33 +56,30 @@ void ui_client_run(bool remote_ui)
loop_poll_events(&main_loop, 1);
- Array args = ARRAY_DICT_INIT;
- Dictionary opts = ARRAY_DICT_INIT;
-
- PUT(opts, "rgb", BOOLEAN_OBJ(true));
- PUT(opts, "ext_linegrid", BOOLEAN_OBJ(true));
- PUT(opts, "ext_termcolors", BOOLEAN_OBJ(true));
-
+ MAXSIZE_TEMP_ARRAY(args, 3);
+ ADD_C(args, INTEGER_OBJ(Columns));
+ ADD_C(args, INTEGER_OBJ(Rows));
+
+ MAXSIZE_TEMP_DICT(opts, 9);
+ PUT_C(opts, "rgb", BOOLEAN_OBJ(true));
+ PUT_C(opts, "ext_linegrid", BOOLEAN_OBJ(true));
+ PUT_C(opts, "ext_termcolors", BOOLEAN_OBJ(true));
if (ui_client_termname) {
- PUT(opts, "term_name", STRING_OBJ(cstr_as_string(ui_client_termname)));
+ PUT_C(opts, "term_name", STRING_OBJ(cstr_as_string(ui_client_termname)));
}
if (ui_client_bg_respose != kNone) {
bool is_dark = (ui_client_bg_respose == kTrue);
- PUT(opts, "term_background", STRING_OBJ(cstr_as_string(is_dark ? "dark" : "light")));
+ PUT_C(opts, "term_background", STRING_OBJ(cstr_as_string(is_dark ? "dark" : "light")));
}
- PUT(opts, "term_colors", INTEGER_OBJ(t_colors));
+ PUT_C(opts, "term_colors", INTEGER_OBJ(t_colors));
if (!remote_ui) {
- PUT(opts, "stdin_tty", BOOLEAN_OBJ(stdin_isatty));
- PUT(opts, "stdout_tty", BOOLEAN_OBJ(stdout_isatty));
+ PUT_C(opts, "stdin_tty", BOOLEAN_OBJ(stdin_isatty));
+ PUT_C(opts, "stdout_tty", BOOLEAN_OBJ(stdout_isatty));
if (ui_client_forward_stdin) {
- PUT(opts, "stdin_fd", INTEGER_OBJ(UI_CLIENT_STDIN_FD));
+ PUT_C(opts, "stdin_fd", INTEGER_OBJ(UI_CLIENT_STDIN_FD));
}
}
-
- ADD(args, INTEGER_OBJ(Columns));
- ADD(args, INTEGER_OBJ(Rows));
- ADD(args, DICTIONARY_OBJ(opts));
-
+ ADD_C(args, DICTIONARY_OBJ(opts));
rpc_send_event(ui_client_channel_id, "nvim_ui_attach", args);
ui_client_attached = true;