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/generators | |
| 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/generators')
| -rwxr-xr-x | src/nvim/generators/gen_api_ui_events.lua | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/nvim/generators/gen_api_ui_events.lua b/src/nvim/generators/gen_api_ui_events.lua index 99dfac05e8..93bbaab74c 100755 --- a/src/nvim/generators/gen_api_ui_events.lua +++ b/src/nvim/generators/gen_api_ui_events.lua @@ -36,20 +36,12 @@ local function write_signature(output, ev, prefix, notype) output:write(')') end -local function write_arglist(output, ev, need_copy) - output:write(' Array args = ARRAY_DICT_INIT;\n') +local function write_arglist(output, ev) for j = 1, #ev.parameters do local param = ev.parameters[j] local kind = string.upper(param[1]) - local do_copy = need_copy and (kind == "ARRAY" or kind == "DICTIONARY" or kind == "STRING" or kind == "OBJECT") - output:write(' ADD(args, ') - if do_copy then - output:write('copy_object(') - end + output:write(' ADD_C(args, ') output:write(kind..'_OBJ('..param[2]..')') - if do_copy then - output:write(')') - end output:write(');\n') end end @@ -119,7 +111,9 @@ for i = 1, #events do remote_output:write('static void remote_ui_'..ev.name) write_signature(remote_output, ev, 'UI *ui') remote_output:write('\n{\n') - write_arglist(remote_output, ev, true) + remote_output:write(' UIData *data = ui->data;\n') + remote_output:write(' Array args = data->call_buf;\n') + write_arglist(remote_output, ev) remote_output:write(' push_call(ui, "'..ev.name..'", args);\n') remote_output:write('}\n\n') end @@ -186,9 +180,10 @@ for i = 1, #events do write_signature(call_output, ev, '') call_output:write('\n{\n') if ev.remote_only then - write_arglist(call_output, ev, false) + call_output:write(' Array args = call_buf;\n') + write_arglist(call_output, ev) call_output:write(' UI_LOG('..ev.name..');\n') - call_output:write(' ui_event("'..ev.name..'", args);\n') + call_output:write(' ui_call_event("'..ev.name..'", args);\n') elseif ev.compositor_impl then call_output:write(' UI_CALL') write_signature(call_output, ev, '!ui->composed, '..ev.name..', ui', true) |