diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-06-08 22:02:02 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2022-06-20 12:44:56 +0200 |
commit | 5d6987210578f5f1c3151988b99a9411f9603374 (patch) | |
tree | c8d1b70ef948a4beafe82195431f1c6607fbe8b7 /src/nvim/ui.c | |
parent | b2ed439bd5ab1b431bb61f8754554c48453495c5 (diff) | |
download | rneovim-5d6987210578f5f1c3151988b99a9411f9603374.tar.gz rneovim-5d6987210578f5f1c3151988b99a9411f9603374.tar.bz2 rneovim-5d6987210578f5f1c3151988b99a9411f9603374.zip |
perf(ui): reduce allocation overhead when encoding "redraw" events
Note for external UIs: Nvim can now emit multiple "redraw" event batches
before a final "flush" event is received. To retain existing behavior,
clients should make sure to update visible state at an explicit "flush"
event, not just the end of a "redraw" batch of event.
* Get rid of copy_object() blizzard in the auto-generated ui_event layer
* Special case "grid_line" by encoding screen state directly to
msgpack events with no intermediate API events.
* Get rid of the arcane notion of referring to the screen as the "shell"
* Array and Dictionary are kvec_t:s, so define them as such.
* Allow kvec_t:s, such as Arrays and Dictionaries, to be allocated with
a predetermined size within an arena.
* Eliminate redundant capacity checking when filling such kvec_t:s
with values.
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r-- | src/nvim/ui.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 3e715793e6..0ac7f4a55f 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -64,6 +64,8 @@ static handle_T cursor_grid_handle = DEFAULT_GRID_HANDLE; static bool has_mouse = false; static int pending_has_mouse = -1; +static Array call_buf = ARRAY_DICT_INIT; + #if MIN_LOG_LEVEL > LOGLVL_DBG # define UI_LOG(funname) #else @@ -123,6 +125,12 @@ void ui_init(void) default_grid.handle = 1; msg_grid_adj.target = &default_grid; ui_comp_init(); + kv_ensure_space(call_buf, 16); +} + +void ui_free_all_mem(void) +{ + kv_destroy(call_buf); } void ui_builtin_start(void) @@ -173,15 +181,6 @@ bool ui_active(void) return ui_count > 1; } -void ui_event(char *name, Array args) -{ - bool args_consumed = false; - ui_call_event(name, args, &args_consumed); - if (!args_consumed) { - api_free_array(args); - } -} - void ui_refresh(void) { if (!ui_active()) { |