diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-07-19 13:08:11 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-19 13:08:11 +0200 |
commit | 101fd04ee2036b125a93f3e71dbaa4ae6917ce8b (patch) | |
tree | 424ebcabeecf4c0e88cb5b7b7cb6e407bc11de63 /src/nvim/api/ui.c | |
parent | 93bd6fb2c8e1f68a48169a63caae1fc0b4797a8a (diff) | |
parent | f87c8245133dd8116a9bab2d2e89f9b26967c7a8 (diff) | |
download | rneovim-101fd04ee2036b125a93f3e71dbaa4ae6917ce8b.tar.gz rneovim-101fd04ee2036b125a93f3e71dbaa4ae6917ce8b.tar.bz2 rneovim-101fd04ee2036b125a93f3e71dbaa4ae6917ce8b.zip |
Merge pull request #19409 from bfredl/uiunpack
perf(ui): some ui_client fixes/optimizations before externalized TUI
Diffstat (limited to 'src/nvim/api/ui.c')
-rw-r--r-- | src/nvim/api/ui.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 54ce838b9b..aa7bed1132 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -748,8 +748,10 @@ static void remote_ui_hl_attr_define(UI *ui, Integer id, HlAttrs rgb_attrs, HlAt UIData *data = ui->data; Array args = data->call_buf; ADD_C(args, INTEGER_OBJ(id)); - ADD_C(args, DICTIONARY_OBJ(hlattrs2dict(rgb_attrs, true))); - ADD_C(args, DICTIONARY_OBJ(hlattrs2dict(cterm_attrs, false))); + MAXSIZE_TEMP_DICT(rgb, 16); + MAXSIZE_TEMP_DICT(cterm, 16); + ADD_C(args, DICTIONARY_OBJ(hlattrs2dict(&rgb, rgb_attrs, true))); + ADD_C(args, DICTIONARY_OBJ(hlattrs2dict(&cterm, cterm_attrs, false))); if (ui->ui_ext[kUIHlState]) { ADD_C(args, ARRAY_OBJ(info)); @@ -758,9 +760,6 @@ static void remote_ui_hl_attr_define(UI *ui, Integer id, HlAttrs rgb_attrs, HlAt } push_call(ui, "hl_attr_define", args); - // TODO(bfredl): could be elided - api_free_dictionary(kv_A(args, 1).data.dictionary); - api_free_dictionary(kv_A(args, 2).data.dictionary); } static void remote_ui_highlight_set(UI *ui, int id) @@ -772,11 +771,9 @@ static void remote_ui_highlight_set(UI *ui, int id) return; } data->hl_id = id; - Dictionary hl = hlattrs2dict(syn_attr2entry(id), ui->rgb); - - ADD_C(args, DICTIONARY_OBJ(hl)); + MAXSIZE_TEMP_DICT(dict, 16); + ADD_C(args, DICTIONARY_OBJ(hlattrs2dict(&dict, syn_attr2entry(id), ui->rgb))); push_call(ui, "highlight_set", args); - api_free_dictionary(kv_A(args, 0).data.dictionary); } /// "true" cursor used only for input focus @@ -963,7 +960,7 @@ static Array translate_contents(UI *ui, Array contents) Array new_item = ARRAY_DICT_INIT; int attr = (int)item.items[0].data.integer; if (attr) { - Dictionary rgb_attrs = hlattrs2dict(syn_attr2entry(attr), ui->rgb); + Dictionary rgb_attrs = hlattrs2dict(NULL, syn_attr2entry(attr), ui->rgb); ADD(new_item, DICTIONARY_OBJ(rgb_attrs)); } else { ADD(new_item, DICTIONARY_OBJ((Dictionary)ARRAY_DICT_INIT)); |