aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjörn Linse <bjorn.linse@gmail.com>2021-08-22 13:12:58 +0200
committerGitHub <noreply@github.com>2021-08-22 13:12:58 +0200
commit7ebb25cca193063f0a3ff2ec8b6206e0832e1215 (patch)
treefbcfa265403eeaac463038c2b08cd2475f267b30 /src
parent3d3c0c669d054ef49304223e3b91ac820996d1e0 (diff)
parentc265fd31ab2b0307650ad94e1ea272e9360c345f (diff)
downloadrneovim-7ebb25cca193063f0a3ff2ec8b6206e0832e1215.tar.gz
rneovim-7ebb25cca193063f0a3ff2ec8b6206e0832e1215.tar.bz2
rneovim-7ebb25cca193063f0a3ff2ec8b6206e0832e1215.zip
Merge pull request #15451 from bfredl/metamap
perf(map): get rid of unnecessary pointer indirections for maps.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/private/handle.c40
-rw-r--r--src/nvim/api/private/handle.h24
-rw-r--r--src/nvim/api/private/helpers.c3
-rw-r--r--src/nvim/api/private/helpers.h8
-rw-r--r--src/nvim/api/ui.c38
-rw-r--r--src/nvim/api/vim.c16
-rw-r--r--src/nvim/api/vim.h2
-rw-r--r--src/nvim/autocmd.c6
-rw-r--r--src/nvim/buffer.c5
-rw-r--r--src/nvim/buffer_defs.h4
-rw-r--r--src/nvim/decoration.c11
-rw-r--r--src/nvim/eval.c2
-rw-r--r--src/nvim/extmark.c44
-rw-r--r--src/nvim/fileio.c2
-rw-r--r--src/nvim/getchar.c1
-rw-r--r--src/nvim/highlight.c58
-rw-r--r--src/nvim/lua/executor.c1
-rw-r--r--src/nvim/lua/treesitter.c2
-rw-r--r--src/nvim/main.c6
-rw-r--r--src/nvim/map.c47
-rw-r--r--src/nvim/map.h17
-rw-r--r--src/nvim/marktree.c7
-rw-r--r--src/nvim/marktree.h2
-rw-r--r--src/nvim/os_unix.c1
-rw-r--r--src/nvim/syntax.c15
-rw-r--r--src/nvim/terminal.c1
-rw-r--r--src/nvim/window.c9
27 files changed, 135 insertions, 237 deletions
diff --git a/src/nvim/api/private/handle.c b/src/nvim/api/private/handle.c
deleted file mode 100644
index eb96192af2..0000000000
--- a/src/nvim/api/private/handle.c
+++ /dev/null
@@ -1,40 +0,0 @@
-// This is an open source non-commercial project. Dear PVS-Studio, please check
-// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
-
-#include <assert.h>
-#include <stdint.h>
-
-#include "nvim/vim.h"
-#include "nvim/map.h"
-#include "nvim/api/private/handle.h"
-
-#define HANDLE_INIT(name) name##_handles = pmap_new(handle_T)()
-
-#define HANDLE_IMPL(type, name) \
- static PMap(handle_T) *name##_handles = NULL; /* NOLINT */ \
- \
- type *handle_get_##name(handle_T handle) \
- { \
- return pmap_get(handle_T)(name##_handles, handle); \
- } \
- \
- void handle_register_##name(type *name) \
- { \
- pmap_put(handle_T)(name##_handles, name->handle, name); \
- } \
- \
- void handle_unregister_##name(type *name) \
- { \
- pmap_del(handle_T)(name##_handles, name->handle); \
- }
-
-HANDLE_IMPL(buf_T, buffer)
-HANDLE_IMPL(win_T, window)
-HANDLE_IMPL(tabpage_T, tabpage)
-
-void handle_init(void)
-{
- HANDLE_INIT(buffer);
- HANDLE_INIT(window);
- HANDLE_INIT(tabpage);
-}
diff --git a/src/nvim/api/private/handle.h b/src/nvim/api/private/handle.h
deleted file mode 100644
index 26e9dc3314..0000000000
--- a/src/nvim/api/private/handle.h
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef NVIM_API_PRIVATE_HANDLE_H
-#define NVIM_API_PRIVATE_HANDLE_H
-
-#include "nvim/vim.h"
-#include "nvim/buffer_defs.h"
-#include "nvim/api/private/defs.h"
-
-#define HANDLE_DECLS(type, name) \
- type *handle_get_##name(handle_T handle); \
- void handle_register_##name(type *name); \
- void handle_unregister_##name(type *name);
-
-// handle_get_buffer handle_register_buffer, handle_unregister_buffer
-HANDLE_DECLS(buf_T, buffer)
-// handle_get_window handle_register_window, handle_unregister_window
-HANDLE_DECLS(win_T, window)
-// handle_get_tabpage handle_register_tabpage, handle_unregister_tabpage
-HANDLE_DECLS(tabpage_T, tabpage)
-
-void handle_init(void);
-
-
-#endif // NVIM_API_PRIVATE_HANDLE_H
-
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 3ec6151090..6114500277 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -9,7 +9,6 @@
#include "nvim/api/private/helpers.h"
#include "nvim/api/private/defs.h"
-#include "nvim/api/private/handle.h"
#include "nvim/api/vim.h"
#include "nvim/msgpack_rpc/helpers.h"
#include "nvim/lua/executor.h"
@@ -1725,7 +1724,7 @@ const char *describe_ns(NS ns_id)
{
String name;
handle_T id;
- map_foreach(namespace_ids, name, id, {
+ map_foreach((&namespace_ids), name, id, {
if ((NS)id == ns_id && name.size) {
return name.data;
}
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index 055abb797f..ecce6afa26 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -101,6 +101,14 @@
#define api_free_window(value)
#define api_free_tabpage(value)
+EXTERN PMap(handle_T) buffer_handles INIT(= MAP_INIT);
+EXTERN PMap(handle_T) window_handles INIT(= MAP_INIT);
+EXTERN PMap(handle_T) tabpage_handles INIT(= MAP_INIT);
+
+#define handle_get_buffer(h) pmap_get(handle_T)(&buffer_handles, (h))
+#define handle_get_window(h) pmap_get(handle_T)(&window_handles, (h))
+#define handle_get_tabpage(h) pmap_get(handle_T)(&tabpage_handles, (h))
+
/// Structure used for saving state for :try
///
/// Used when caller is supposed to be operating when other VimL code is being
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 63e6ad883a..713980ca68 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -37,24 +37,18 @@ typedef struct {
bool wildmenu_active;
} UIData;
-static PMap(uint64_t) *connected_uis = NULL;
-
-void remote_ui_init(void)
- FUNC_API_NOEXPORT
-{
- connected_uis = pmap_new(uint64_t)();
-}
+static PMap(uint64_t) connected_uis = MAP_INIT;
void remote_ui_disconnect(uint64_t channel_id)
FUNC_API_NOEXPORT
{
- UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ UI *ui = pmap_get(uint64_t)(&connected_uis, channel_id);
if (!ui) {
return;
}
UIData *data = ui->data;
api_free_array(data->buffer); // Destroy pending screen updates.
- pmap_del(uint64_t)(connected_uis, channel_id);
+ pmap_del(uint64_t)(&connected_uis, channel_id);
xfree(ui->data);
ui->data = NULL; // Flag UI as "stopped".
ui_detach_impl(ui, channel_id);
@@ -73,7 +67,7 @@ void remote_ui_wait_for_attach(void)
}
LOOP_PROCESS_EVENTS_UNTIL(&main_loop, channel->events, -1,
- pmap_has(uint64_t)(connected_uis, CHAN_STDIO));
+ pmap_has(uint64_t)(&connected_uis, CHAN_STDIO));
}
/// Activates UI events on the channel.
@@ -95,7 +89,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
Dictionary options, Error *err)
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
{
- if (pmap_has(uint64_t)(connected_uis, channel_id)) {
+ if (pmap_has(uint64_t)(&connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException,
"UI already attached to channel: %" PRId64, channel_id);
return;
@@ -172,7 +166,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
data->wildmenu_active = false;
ui->data = data;
- pmap_put(uint64_t)(connected_uis, channel_id, ui);
+ pmap_put(uint64_t)(&connected_uis, channel_id, ui);
ui_attach_impl(ui, channel_id);
}
@@ -195,7 +189,7 @@ void ui_attach(uint64_t channel_id, Integer width, Integer height,
void nvim_ui_detach(uint64_t channel_id, Error *err)
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
{
- if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
+ if (!pmap_has(uint64_t)(&connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException,
"UI not attached to channel: %" PRId64, channel_id);
return;
@@ -208,7 +202,7 @@ void nvim_ui_try_resize(uint64_t channel_id, Integer width,
Integer height, Error *err)
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
{
- if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
+ if (!pmap_has(uint64_t)(&connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException,
"UI not attached to channel: %" PRId64, channel_id);
return;
@@ -220,7 +214,7 @@ void nvim_ui_try_resize(uint64_t channel_id, Integer width,
return;
}
- UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ UI *ui = pmap_get(uint64_t)(&connected_uis, channel_id);
ui->width = (int)width;
ui->height = (int)height;
ui_refresh();
@@ -230,12 +224,12 @@ void nvim_ui_set_option(uint64_t channel_id, String name,
Object value, Error *error)
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
{
- if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
+ if (!pmap_has(uint64_t)(&connected_uis, channel_id)) {
api_set_error(error, kErrorTypeException,
"UI not attached to channel: %" PRId64, channel_id);
return;
}
- UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ UI *ui = pmap_get(uint64_t)(&connected_uis, channel_id);
ui_set_option(ui, false, name, value, error);
}
@@ -310,7 +304,7 @@ void nvim_ui_try_resize_grid(uint64_t channel_id, Integer grid, Integer width,
Integer height, Error *err)
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY
{
- if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
+ if (!pmap_has(uint64_t)(&connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException,
"UI not attached to channel: %" PRId64, channel_id);
return;
@@ -328,7 +322,7 @@ void nvim_ui_try_resize_grid(uint64_t channel_id, Integer grid, Integer width,
void nvim_ui_pum_set_height(uint64_t channel_id, Integer height, Error *err)
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY
{
- if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
+ if (!pmap_has(uint64_t)(&connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException,
"UI not attached to channel: %" PRId64, channel_id);
return;
@@ -339,7 +333,7 @@ void nvim_ui_pum_set_height(uint64_t channel_id, Integer height, Error *err)
return;
}
- UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ UI *ui = pmap_get(uint64_t)(&connected_uis, channel_id);
if (!ui->ui_ext[kUIPopupmenu]) {
api_set_error(err, kErrorTypeValidation,
"It must support the ext_popupmenu option");
@@ -369,13 +363,13 @@ void nvim_ui_pum_set_bounds(uint64_t channel_id, Float width, Float height,
Float row, Float col, Error *err)
FUNC_API_SINCE(7) FUNC_API_REMOTE_ONLY
{
- if (!pmap_has(uint64_t)(connected_uis, channel_id)) {
+ if (!pmap_has(uint64_t)(&connected_uis, channel_id)) {
api_set_error(err, kErrorTypeException,
"UI not attached to channel: %" PRId64, channel_id);
return;
}
- UI *ui = pmap_get(uint64_t)(connected_uis, channel_id);
+ UI *ui = pmap_get(uint64_t)(&connected_uis, channel_id);
if (!ui->ui_ext[kUIPopupmenu]) {
api_set_error(err, kErrorTypeValidation,
"UI must support the ext_popupmenu option");
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 400dbb126c..5aed85ef08 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -58,22 +58,16 @@
# include "api/vim.c.generated.h"
#endif
-void api_vim_init(void)
- FUNC_API_NOEXPORT
-{
- namespace_ids = map_new(String, handle_T)();
-}
-
void api_vim_free_all_mem(void)
FUNC_API_NOEXPORT
{
String name;
handle_T id;
- map_foreach(namespace_ids, name, id, {
+ map_foreach((&namespace_ids), name, id, {
(void)id;
xfree(name.data);
})
- map_free(String, handle_T)(namespace_ids);
+ map_destroy(String, handle_T)(&namespace_ids);
}
/// Executes Vimscript (multiline block of Ex-commands), like anonymous
@@ -1568,14 +1562,14 @@ void nvim_set_current_tabpage(Tabpage tabpage, Error *err)
Integer nvim_create_namespace(String name)
FUNC_API_SINCE(5)
{
- handle_T id = map_get(String, handle_T)(namespace_ids, name);
+ handle_T id = map_get(String, handle_T)(&namespace_ids, name);
if (id > 0) {
return id;
}
id = next_namespace_id++;
if (name.size > 0) {
String name_alloc = copy_string(name);
- map_put(String, handle_T)(namespace_ids, name_alloc, id);
+ map_put(String, handle_T)(&namespace_ids, name_alloc, id);
}
return (Integer)id;
}
@@ -1590,7 +1584,7 @@ Dictionary nvim_get_namespaces(void)
String name;
handle_T id;
- map_foreach(namespace_ids, name, id, {
+ map_foreach((&namespace_ids), name, id, {
PUT(retval, name.data, INTEGER_OBJ(id));
})
diff --git a/src/nvim/api/vim.h b/src/nvim/api/vim.h
index d6873da6d2..4fd353ce5c 100644
--- a/src/nvim/api/vim.h
+++ b/src/nvim/api/vim.h
@@ -6,7 +6,7 @@
#include "nvim/api/private/defs.h"
#include "nvim/map.h"
-EXTERN Map(String, handle_T) *namespace_ids INIT(= NULL);
+EXTERN Map(String, handle_T) namespace_ids INIT(= MAP_INIT);
EXTERN handle_T next_namespace_id INIT(= 1);
#ifdef INCLUDE_GENERATED_DECLARATIONS
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c
index bec9808183..417953eb14 100644
--- a/src/nvim/autocmd.c
+++ b/src/nvim/autocmd.c
@@ -5,7 +5,7 @@
#include "nvim/autocmd.h"
-#include "nvim/api/private/handle.h"
+#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/buffer.h"
#include "nvim/charset.h"
@@ -1150,7 +1150,7 @@ void aucmd_prepbuf(aco_save_T *aco, buf_T *buf)
block_autocmds(); // We don't want BufEnter/WinEnter autocommands.
if (need_append) {
win_append(lastwin, aucmd_win);
- handle_register_window(aucmd_win);
+ pmap_put(handle_T)(&window_handles, aucmd_win->handle, aucmd_win);
win_config_float(aucmd_win, aucmd_win->w_float_config);
}
// Prevent chdir() call in win_enter_ext(), through do_autochdir()
@@ -1191,7 +1191,7 @@ void aucmd_restbuf(aco_save_T *aco)
win_found:
win_remove(curwin, NULL);
- handle_unregister_window(curwin);
+ pmap_del(handle_T)(&window_handles, curwin->handle);
if (curwin->w_grid_alloc.chars != NULL) {
ui_comp_remove_grid(&curwin->w_grid_alloc);
ui_call_win_hide(curwin->w_grid_alloc.handle);
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c
index a7fc34f2d6..fdb3ffdc7e 100644
--- a/src/nvim/buffer.c
+++ b/src/nvim/buffer.c
@@ -24,7 +24,6 @@
#include <inttypes.h>
#include <assert.h>
-#include "nvim/api/private/handle.h"
#include "nvim/api/private/helpers.h"
#include "nvim/api/vim.h"
#include "nvim/ascii.h"
@@ -757,7 +756,7 @@ void buf_freeall(buf_T *buf, int flags)
*/
static void free_buffer(buf_T *buf)
{
- handle_unregister_buffer(buf);
+ pmap_del(handle_T)(&buffer_handles, buf->b_fnum);
buf_free_count++;
// b:changedtick uses an item in buf_T.
free_buffer_stuff(buf, kBffClearWinInfo);
@@ -1841,7 +1840,7 @@ buf_T *buflist_new(char_u *ffname_arg, char_u *sfname_arg, linenr_T lnum,
lastbuf = buf;
buf->b_fnum = top_file_num++;
- handle_register_buffer(buf);
+ pmap_put(handle_T)(&buffer_handles, buf->b_fnum, buf);
if (top_file_num < 0) { // wrap around (may cause duplicates)
EMSG(_("W14: Warning: List of file names overflow"));
if (emsg_silent == 0) {
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index b03d69a04c..0ae8dd3664 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -863,8 +863,8 @@ struct file_buffer {
int b_mapped_ctrl_c; // modes where CTRL-C is mapped
MarkTree b_marktree[1];
- Map(uint64_t, ExtmarkItem) *b_extmark_index;
- Map(uint64_t, ExtmarkNs) *b_extmark_ns; // extmark namespaces
+ Map(uint64_t, ExtmarkItem) b_extmark_index[1];
+ Map(uint64_t, ExtmarkNs) b_extmark_ns[1]; // extmark namespaces
// array of channel_id:s which have asked to receive updates for this
// buffer.
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 74cb9a26b7..5168ed6d0f 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -13,12 +13,7 @@
# include "decoration.c.generated.h"
#endif
-static PMap(uint64_t) *hl_decors;
-
-void decor_init(void)
-{
- hl_decors = pmap_new(uint64_t)();
-}
+static PMap(uint64_t) hl_decors;
/// Add highlighting to a buffer, bounded by two cursor positions,
/// with an offset.
@@ -77,7 +72,7 @@ void bufhl_add_hl_pos_offset(buf_T *buf,
Decoration *decor_hl(int hl_id)
{
assert(hl_id > 0);
- Decoration **dp = (Decoration **)pmap_ref(uint64_t)(hl_decors,
+ Decoration **dp = (Decoration **)pmap_ref(uint64_t)(&hl_decors,
(uint64_t)hl_id, true);
if (*dp) {
return *dp;
@@ -150,7 +145,7 @@ bool decor_redraw_reset(buf_T *buf, DecorState *state)
}
}
kv_size(state->active) = 0;
- return buf->b_extmark_index;
+ return map_size(buf->b_extmark_index);
}
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 789936fdff..36b04c24bf 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -7331,7 +7331,7 @@ void add_timer_info(typval_T *rettv, timer_T *timer)
void add_timer_info_all(typval_T *rettv)
{
- tv_list_alloc_ret(rettv, timers->table->n_occupied);
+ tv_list_alloc_ret(rettv, map_size(timers));
timer_T *timer;
map_foreach_value(timers, timer, {
if (!timer->stopped) {
diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c
index 4b2dccd8a4..510f3a4254 100644
--- a/src/nvim/extmark.c
+++ b/src/nvim/extmark.c
@@ -48,20 +48,7 @@
#endif
static ExtmarkNs *buf_ns_ref(buf_T *buf, uint64_t ns_id, bool put) {
- if (!buf->b_extmark_ns) {
- if (!put) {
- return NULL;
- }
- buf->b_extmark_ns = map_new(uint64_t, ExtmarkNs)();
- buf->b_extmark_index = map_new(uint64_t, ExtmarkItem)();
- }
-
- ExtmarkNs *ns = map_ref(uint64_t, ExtmarkNs)(buf->b_extmark_ns, ns_id, put);
- if (put && ns->map == NULL) {
- ns->map = map_new(uint64_t, uint64_t)();
- ns->free_id = 1;
- }
- return ns;
+ return map_ref(uint64_t, ExtmarkNs)(buf->b_extmark_ns, ns_id, put);
}
@@ -195,7 +182,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
int l_row, colnr_T l_col,
int u_row, colnr_T u_col)
{
- if (!buf->b_extmark_ns) {
+ if (!map_size(buf->b_extmark_ns)) {
return false;
}
@@ -215,12 +202,9 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
}
// the value is either zero or the lnum (row+1) if highlight was present.
- static Map(uint64_t, ssize_t) *delete_set = NULL;
+ static Map(uint64_t, ssize_t) delete_set = MAP_INIT;
typedef struct { Decoration *decor; int row1; } DecorItem;
static kvec_t(DecorItem) decors;
- if (delete_set == NULL) {
- delete_set = map_new(uint64_t, ssize_t)();
- }
MarkTreeIter itr[1] = { 0 };
marktree_itr_get(buf->b_marktree, l_row, l_col, itr);
@@ -231,7 +215,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
|| (mark.row == u_row && mark.col > u_col)) {
break;
}
- ssize_t *del_status = map_ref(uint64_t, ssize_t)(delete_set, mark.id,
+ ssize_t *del_status = map_ref(uint64_t, ssize_t)(&delete_set, mark.id,
false);
if (del_status) {
marktree_del_itr(buf->b_marktree, itr, false);
@@ -240,7 +224,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
decor_redraw(buf, it.row1, mark.row, it.decor);
decor_free(it.decor);
}
- map_del(uint64_t, ssize_t)(delete_set, mark.id);
+ map_del(uint64_t, ssize_t)(&delete_set, mark.id);
continue;
}
@@ -261,7 +245,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
kv_push(decors,
((DecorItem) { .decor = item.decor, .row1 = mark.row }));
}
- map_put(uint64_t, ssize_t)(delete_set, other, decor_id);
+ map_put(uint64_t, ssize_t)(&delete_set, other, decor_id);
} else if (item.decor) {
decor_redraw(buf, mark.row, mark.row, item.decor);
decor_free(item.decor);
@@ -276,7 +260,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
}
uint64_t id;
ssize_t decor_id;
- map_foreach(delete_set, id, decor_id, {
+ map_foreach((&delete_set), id, decor_id, {
mtpos_t pos = marktree_lookup(buf->b_marktree, id, itr);
assert(itr->node);
marktree_del_itr(buf->b_marktree, itr, false);
@@ -286,7 +270,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
decor_free(it.decor);
}
});
- map_clear(uint64_t, ssize_t)(delete_set);
+ map_clear(uint64_t, ssize_t)(&delete_set);
kv_size(decors) = 0;
return marks_cleared;
}
@@ -383,7 +367,7 @@ ExtmarkInfo extmark_from_id(buf_T *buf, uint64_t ns_id, uint64_t id)
// free extmarks from the buffer
void extmark_free_all(buf_T *buf)
{
- if (!buf->b_extmark_ns) {
+ if (!map_size(buf->b_extmark_ns)) {
return;
}
@@ -395,17 +379,17 @@ void extmark_free_all(buf_T *buf)
map_foreach(buf->b_extmark_ns, id, ns, {
(void)id;
- map_free(uint64_t, uint64_t)(ns.map);
+ map_destroy(uint64_t, uint64_t)(ns.map);
});
- map_free(uint64_t, ExtmarkNs)(buf->b_extmark_ns);
- buf->b_extmark_ns = NULL;
+ map_destroy(uint64_t, ExtmarkNs)(buf->b_extmark_ns);
+ map_init(uint64_t, ExtmarkNs, buf->b_extmark_ns);
map_foreach(buf->b_extmark_index, id, item, {
(void)id;
decor_free(item.decor);
});
- map_free(uint64_t, ExtmarkItem)(buf->b_extmark_index);
- buf->b_extmark_index = NULL;
+ map_destroy(uint64_t, ExtmarkItem)(buf->b_extmark_index);
+ map_init(uint64_t, ExtmarkItem, buf->b_extmark_index);
}
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index ee8be8429f..3d058e1d09 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -11,7 +11,7 @@
#include <fcntl.h>
#include "nvim/vim.h"
-#include "nvim/api/private/handle.h"
+#include "nvim/api/private/helpers.h"
#include "nvim/ascii.h"
#include "nvim/fileio.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 2b6c5b9f37..28f58e2c34 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -52,7 +52,6 @@
#include "nvim/os/input.h"
#include "nvim/os/os.h"
#include "nvim/os/fileio.h"
-#include "nvim/api/private/handle.h"
/// Index in scriptin
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c
index 29ee7aae56..7341ac9393 100644
--- a/src/nvim/highlight.c
+++ b/src/nvim/highlight.c
@@ -25,22 +25,16 @@ static bool hlstate_active = false;
static kvec_t(HlEntry) attr_entries = KV_INITIAL_VALUE;
-static Map(HlEntry, int) *attr_entry_ids;
-static Map(int, int) *combine_attr_entries;
-static Map(int, int) *blend_attr_entries;
-static Map(int, int) *blendthrough_attr_entries;
+static Map(HlEntry, int) attr_entry_ids = MAP_INIT;
+static Map(int, int) combine_attr_entries = MAP_INIT;
+static Map(int, int) blend_attr_entries = MAP_INIT;
+static Map(int, int) blendthrough_attr_entries = MAP_INIT;
/// highlight entries private to a namespace
-static Map(ColorKey, ColorItem) *ns_hl;
+static Map(ColorKey, ColorItem) ns_hl;
void highlight_init(void)
{
- attr_entry_ids = map_new(HlEntry, int)();
- combine_attr_entries = map_new(int, int)();
- blend_attr_entries = map_new(int, int)();
- blendthrough_attr_entries = map_new(int, int)();
- ns_hl = map_new(ColorKey, ColorItem)();
-
// index 0 is no attribute, add dummy entry:
kv_push(attr_entries, ((HlEntry){ .attr = HLATTRS_INIT, .kind = kHlUnknown,
.id1 = 0, .id2 = 0 }));
@@ -71,7 +65,7 @@ static int get_attr_entry(HlEntry entry)
entry.id2 = 0;
}
- int id = map_get(HlEntry, int)(attr_entry_ids, entry);
+ int id = map_get(HlEntry, int)(&attr_entry_ids, entry);
if (id > 0) {
return id;
}
@@ -104,7 +98,7 @@ static int get_attr_entry(HlEntry entry)
id = (int)next_id;
kv_push(attr_entries, entry);
- map_put(HlEntry, int)(attr_entry_ids, entry, id);
+ map_put(HlEntry, int)(&attr_entry_ids, entry, id);
Array inspect = hl_inspect(id);
@@ -154,7 +148,7 @@ void ns_hl_def(NS ns_id, int hl_id, HlAttrs attrs, int link_id)
{
DecorProvider *p = get_decor_provider(ns_id, true);
if ((attrs.rgb_ae_attr & HL_DEFAULT)
- && map_has(ColorKey, ColorItem)(ns_hl, ColorKey(ns_id, hl_id))) {
+ && map_has(ColorKey, ColorItem)(&ns_hl, ColorKey(ns_id, hl_id))) {
return;
}
int attr_id = link_id > 0 ? -1 : hl_get_syn_attr(ns_id, hl_id, attrs);
@@ -162,7 +156,7 @@ void ns_hl_def(NS ns_id, int hl_id, HlAttrs attrs, int link_id)
.link_id = link_id,
.version = p->hl_valid,
.is_default = (attrs.rgb_ae_attr & HL_DEFAULT) };
- map_put(ColorKey, ColorItem)(ns_hl, ColorKey(ns_id, hl_id), it);
+ map_put(ColorKey, ColorItem)(&ns_hl, ColorKey(ns_id, hl_id), it);
}
int ns_get_hl(NS ns_id, int hl_id, bool link, bool nodefault)
@@ -177,7 +171,7 @@ int ns_get_hl(NS ns_id, int hl_id, bool link, bool nodefault)
}
DecorProvider *p = get_decor_provider(ns_id, true);
- ColorItem it = map_get(ColorKey, ColorItem)(ns_hl, ColorKey(ns_id, hl_id));
+ ColorItem it = map_get(ColorKey, ColorItem)(&ns_hl, ColorKey(ns_id, hl_id));
// TODO(bfredl): map_ref true even this?
bool valid_cache = it.version >= p->hl_valid;
@@ -220,7 +214,7 @@ int ns_get_hl(NS ns_id, int hl_id, bool link, bool nodefault)
it.attr_id = fallback ? -1 : hl_get_syn_attr((int)ns_id, hl_id, attrs);
it.version = p->hl_valid-tmp;
it.is_default = attrs.rgb_ae_attr & HL_DEFAULT;
- map_put(ColorKey, ColorItem)(ns_hl, ColorKey(ns_id, hl_id), it);
+ map_put(ColorKey, ColorItem)(&ns_hl, ColorKey(ns_id, hl_id), it);
}
if (it.is_default && nodefault) {
@@ -395,28 +389,28 @@ void clear_hl_tables(bool reinit)
{
if (reinit) {
kv_size(attr_entries) = 1;
- map_clear(HlEntry, int)(attr_entry_ids);
- map_clear(int, int)(combine_attr_entries);
- map_clear(int, int)(blend_attr_entries);
- map_clear(int, int)(blendthrough_attr_entries);
+ map_clear(HlEntry, int)(&attr_entry_ids);
+ map_clear(int, int)(&combine_attr_entries);
+ map_clear(int, int)(&blend_attr_entries);
+ map_clear(int, int)(&blendthrough_attr_entries);
memset(highlight_attr_last, -1, sizeof(highlight_attr_last));
highlight_attr_set_all();
highlight_changed();
screen_invalidate_highlights();
} else {
kv_destroy(attr_entries);
- map_free(HlEntry, int)(attr_entry_ids);
- map_free(int, int)(combine_attr_entries);
- map_free(int, int)(blend_attr_entries);
- map_free(int, int)(blendthrough_attr_entries);
- map_free(ColorKey, ColorItem)(ns_hl);
+ map_destroy(HlEntry, int)(&attr_entry_ids);
+ map_destroy(int, int)(&combine_attr_entries);
+ map_destroy(int, int)(&blend_attr_entries);
+ map_destroy(int, int)(&blendthrough_attr_entries);
+ map_destroy(ColorKey, ColorItem)(&ns_hl);
}
}
void hl_invalidate_blends(void)
{
- map_clear(int, int)(blend_attr_entries);
- map_clear(int, int)(blendthrough_attr_entries);
+ map_clear(int, int)(&blend_attr_entries);
+ map_clear(int, int)(&blendthrough_attr_entries);
highlight_changed();
update_window_hl(curwin, true);
}
@@ -437,7 +431,7 @@ int hl_combine_attr(int char_attr, int prim_attr)
// TODO(bfredl): could use a struct for clearer intent.
int combine_tag = (char_attr << 16) + prim_attr;
- int id = map_get(int, int)(combine_attr_entries, combine_tag);
+ int id = map_get(int, int)(&combine_attr_entries, combine_tag);
if (id > 0) {
return id;
}
@@ -494,7 +488,7 @@ int hl_combine_attr(int char_attr, int prim_attr)
id = get_attr_entry((HlEntry){ .attr = new_en, .kind = kHlCombine,
.id1 = char_attr, .id2 = prim_attr });
if (id > 0) {
- map_put(int, int)(combine_attr_entries, combine_tag, id);
+ map_put(int, int)(&combine_attr_entries, combine_tag, id);
}
return id;
@@ -550,8 +544,8 @@ int hl_blend_attrs(int back_attr, int front_attr, bool *through)
int combine_tag = (back_attr << 16) + front_attr;
Map(int, int) *map = (*through
- ? blendthrough_attr_entries
- : blend_attr_entries);
+ ? &blendthrough_attr_entries
+ : &blend_attr_entries);
int id = map_get(int, int)(map, combine_tag);
if (id > 0) {
return id;
diff --git a/src/nvim/lua/executor.c b/src/nvim/lua/executor.c
index 7fa7a7d94e..8779d16116 100644
--- a/src/nvim/lua/executor.c
+++ b/src/nvim/lua/executor.c
@@ -13,7 +13,6 @@
#include "nvim/func_attr.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/api/private/handle.h"
#include "nvim/api/vim.h"
#include "nvim/msgpack_rpc/channel.h"
#include "nvim/vim.h"
diff --git a/src/nvim/lua/treesitter.c b/src/nvim/lua/treesitter.c
index 1425baacf0..14fed0d474 100644
--- a/src/nvim/lua/treesitter.c
+++ b/src/nvim/lua/treesitter.c
@@ -18,7 +18,7 @@
#include "tree_sitter/api.h"
#include "nvim/lua/treesitter.h"
-#include "nvim/api/private/handle.h"
+#include "nvim/api/private/helpers.h"
#include "nvim/memline.h"
#include "nvim/buffer.h"
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 136608afdf..9fc82a75af 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -78,7 +78,6 @@
#include "nvim/api/ui.h"
#include "nvim/api/private/defs.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/api/private/handle.h"
#include "nvim/api/private/dispatch.h"
#ifndef WIN32
# include "nvim/os/pty_process_unix.h"
@@ -126,8 +125,6 @@ void event_init(void)
signal_init();
// finish mspgack-rpc initialization
channel_init();
- remote_ui_init();
- api_vim_init();
terminal_init();
ui_init();
}
@@ -160,13 +157,10 @@ void early_init(mparm_T *paramp)
{
env_init();
fs_init();
- handle_init();
- decor_init();
eval_init(); // init global variables
init_path(argv0 ? argv0 : "nvim");
init_normal_cmds(); // Init the table of Normal mode commands.
highlight_init();
- syntax_init();
#ifdef WIN32
OSVERSIONINFO ovi;
diff --git a/src/nvim/map.c b/src/nvim/map.c
index 86dc257e40..d956699b21 100644
--- a/src/nvim/map.c
+++ b/src/nvim/map.c
@@ -56,54 +56,59 @@
\
Map(T, U) *map_##T##_##U##_new() \
{ \
- Map(T, U) *rv = xmalloc(sizeof(Map(T, U))); \
- rv->table = kh_init(T##_##U##_map); \
+ Map(T, U) *rv = xcalloc(1, sizeof(Map(T, U))); \
+ /* khash_t table member is zero-initialized */ \
return rv; \
} \
\
void map_##T##_##U##_free(Map(T, U) *map) \
{ \
- kh_destroy(T##_##U##_map, map->table); \
+ kh_dealloc(T##_##U##_map, &map->table); \
xfree(map); \
} \
\
+ void map_##T##_##U##_destroy(Map(T, U) *map) \
+ { \
+ kh_dealloc(T##_##U##_map, &map->table); \
+ } \
+ \
U map_##T##_##U##_get(Map(T, U) *map, T key) \
{ \
khiter_t k; \
\
- if ((k = kh_get(T##_##U##_map, map->table, key)) == kh_end(map->table)) { \
+ if ((k = kh_get(T##_##U##_map, &map->table, key)) == kh_end(&map->table)) { \
return INITIALIZER(T, U); \
} \
\
- return kh_val(map->table, k); \
+ return kh_val(&map->table, k); \
} \
\
bool map_##T##_##U##_has(Map(T, U) *map, T key) \
{ \
- return kh_get(T##_##U##_map, map->table, key) != kh_end(map->table); \
+ return kh_get(T##_##U##_map, &map->table, key) != kh_end(&map->table); \
} \
\
T map_##T##_##U##_key(Map(T, U) *map, T key) \
{ \
khiter_t k; \
\
- if ((k = kh_get(T##_##U##_map, map->table, key)) == kh_end(map->table)) { \
+ if ((k = kh_get(T##_##U##_map, &map->table, key)) == kh_end(&map->table)) { \
abort(); /* Caller must check map_has(). */ \
} \
\
- return kh_key(map->table, k); \
+ return kh_key(&map->table, k); \
} \
U map_##T##_##U##_put(Map(T, U) *map, T key, U value) \
{ \
int ret; \
U rv = INITIALIZER(T, U); \
- khiter_t k = kh_put(T##_##U##_map, map->table, key, &ret); \
+ khiter_t k = kh_put(T##_##U##_map, &map->table, key, &ret); \
\
if (!ret) { \
- rv = kh_val(map->table, k); \
+ rv = kh_val(&map->table, k); \
} \
\
- kh_val(map->table, k) = value; \
+ kh_val(&map->table, k) = value; \
return rv; \
} \
\
@@ -112,18 +117,18 @@
int ret; \
khiter_t k; \
if (put) { \
- k = kh_put(T##_##U##_map, map->table, key, &ret); \
+ k = kh_put(T##_##U##_map, &map->table, key, &ret); \
if (ret) { \
- kh_val(map->table, k) = INITIALIZER(T, U); \
+ kh_val(&map->table, k) = INITIALIZER(T, U); \
} \
} else { \
- k = kh_get(T##_##U##_map, map->table, key); \
- if (k == kh_end(map->table)) { \
+ k = kh_get(T##_##U##_map, &map->table, key); \
+ if (k == kh_end(&map->table)) { \
return NULL; \
} \
} \
\
- return &kh_val(map->table, k); \
+ return &kh_val(&map->table, k); \
} \
\
U map_##T##_##U##_del(Map(T, U) *map, T key) \
@@ -131,9 +136,9 @@
U rv = INITIALIZER(T, U); \
khiter_t k; \
\
- if ((k = kh_get(T##_##U##_map, map->table, key)) != kh_end(map->table)) { \
- rv = kh_val(map->table, k); \
- kh_del(T##_##U##_map, map->table, k); \
+ if ((k = kh_get(T##_##U##_map, &map->table, key)) != kh_end(&map->table)) { \
+ rv = kh_val(&map->table, k); \
+ kh_del(T##_##U##_map, &map->table, k); \
} \
\
return rv; \
@@ -141,7 +146,7 @@
\
void map_##T##_##U##_clear(Map(T, U) *map) \
{ \
- kh_clear(T##_##U##_map, map->table); \
+ kh_clear(T##_##U##_map, &map->table); \
}
static inline khint_t String_hash(String s)
@@ -199,7 +204,7 @@ MAP_IMPL(ptr_t, ptr_t, DEFAULT_INITIALIZER)
MAP_IMPL(uint64_t, ptr_t, DEFAULT_INITIALIZER)
MAP_IMPL(uint64_t, ssize_t, SSIZE_INITIALIZER)
MAP_IMPL(uint64_t, uint64_t, DEFAULT_INITIALIZER)
-#define EXTMARK_NS_INITIALIZER { 0, 0 }
+#define EXTMARK_NS_INITIALIZER { { MAP_INIT }, 1 }
MAP_IMPL(uint64_t, ExtmarkNs, EXTMARK_NS_INITIALIZER)
#define EXTMARK_ITEM_INITIALIZER { 0, 0, NULL }
MAP_IMPL(uint64_t, ExtmarkItem, EXTMARK_ITEM_INITIALIZER)
diff --git a/src/nvim/map.h b/src/nvim/map.h
index a35a2c1672..6dc36f77ac 100644
--- a/src/nvim/map.h
+++ b/src/nvim/map.h
@@ -18,11 +18,12 @@
KHASH_DECLARE(T##_##U##_map, T, U) \
\
typedef struct { \
- khash_t(T##_##U##_map) *table; \
+ khash_t(T##_##U##_map) table; \
} Map(T, U); \
\
Map(T, U) *map_##T##_##U##_new(void); \
void map_##T##_##U##_free(Map(T, U) *map); \
+ void map_##T##_##U##_destroy(Map(T, U) *map); \
U map_##T##_##U##_get(Map(T, U) *map, T key); \
bool map_##T##_##U##_has(Map(T, U) *map, T key); \
T map_##T##_##U##_key(Map(T, U) *map, T key); \
@@ -45,7 +46,7 @@ MAP_DECLS(uint64_t, uint64_t)
// NB: this is the only way to define a struct both containing and contained
// in a map...
typedef struct ExtmarkNs { // For namespacing extmarks
- Map(uint64_t, uint64_t) *map; // For fast lookup
+ Map(uint64_t, uint64_t) map[1]; // For fast lookup
uint64_t free_id; // For automatically assigning id's
} ExtmarkNs;
@@ -58,8 +59,12 @@ MAP_DECLS(String, handle_T)
MAP_DECLS(ColorKey, ColorItem)
+#define MAP_INIT { { 0, 0, 0, 0, NULL, NULL, NULL } }
+#define map_init(k, v, map) do { *(map) = (Map(k, v))MAP_INIT; } while (false)
+
#define map_new(T, U) map_##T##_##U##_new
#define map_free(T, U) map_##T##_##U##_free
+#define map_destroy(T, U) map_##T##_##U##_destroy
#define map_get(T, U) map_##T##_##U##_get
#define map_has(T, U) map_##T##_##U##_has
#define map_key(T, U) map_##T##_##U##_key
@@ -68,10 +73,11 @@ MAP_DECLS(ColorKey, ColorItem)
#define map_del(T, U) map_##T##_##U##_del
#define map_clear(T, U) map_##T##_##U##_clear
-#define map_size(map) ((map)->table->size)
+#define map_size(map) ((map)->table.size)
#define pmap_new(T) map_new(T, ptr_t)
#define pmap_free(T) map_free(T, ptr_t)
+#define pmap_destroy(T) map_destroy(T, ptr_t)
#define pmap_get(T) map_get(T, ptr_t)
#define pmap_has(T) map_has(T, ptr_t)
#define pmap_key(T) map_key(T, ptr_t)
@@ -80,12 +86,13 @@ MAP_DECLS(ColorKey, ColorItem)
/// @see pmap_del2
#define pmap_del(T) map_del(T, ptr_t)
#define pmap_clear(T) map_clear(T, ptr_t)
+#define pmap_init(k, map) map_init(k, ptr_t, map)
#define map_foreach(map, key, value, block) \
- kh_foreach(map->table, key, value, block)
+ kh_foreach(&map->table, key, value, block)
#define map_foreach_value(map, value, block) \
- kh_foreach_value(map->table, value, block)
+ kh_foreach_value(&map->table, value, block)
void pmap_del2(PMap(cstr_t) *map, const char *key);
diff --git a/src/nvim/marktree.c b/src/nvim/marktree.c
index d0d843cbf8..a04f250fc3 100644
--- a/src/nvim/marktree.c
+++ b/src/nvim/marktree.c
@@ -250,7 +250,6 @@ void marktree_put_key(MarkTree *b, int row, int col, uint64_t id)
if (!b->root) {
b->root = (mtnode_t *)xcalloc(1, ILEN);
- b->id2node = pmap_new(uint64_t)();
b->n_nodes++;
}
mtnode_t *r, *s;
@@ -547,9 +546,9 @@ void marktree_clear(MarkTree *b)
marktree_free_node(b->root);
b->root = NULL;
}
- if (b->id2node) {
- pmap_free(uint64_t)(b->id2node);
- b->id2node = NULL;
+ if (b->id2node->table.keys) {
+ pmap_destroy(uint64_t)(b->id2node);
+ pmap_init(uint64_t, b->id2node);
}
b->n_keys = 0;
b->n_nodes = 0;
diff --git a/src/nvim/marktree.h b/src/nvim/marktree.h
index 3b83e3c44d..7af23765c3 100644
--- a/src/nvim/marktree.h
+++ b/src/nvim/marktree.h
@@ -63,7 +63,7 @@ typedef struct {
uint64_t next_id;
// TODO(bfredl): the pointer to node could be part of the larger
// Map(uint64_t, ExtmarkItem) essentially;
- PMap(uint64_t) *id2node;
+ PMap(uint64_t) id2node[1];
} MarkTree;
diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c
index be4bd9709b..44274e8f1d 100644
--- a/src/nvim/os_unix.c
+++ b/src/nvim/os_unix.c
@@ -7,7 +7,6 @@
#include <stdbool.h>
#include <string.h>
-#include "nvim/api/private/handle.h"
#include "nvim/vim.h"
#include "nvim/ascii.h"
#include "nvim/os_unix.h"
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index 1d45df8ebd..e73e948481 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -91,7 +91,7 @@ typedef struct hl_group {
// builtin |highlight-groups|
static garray_T highlight_ga = GA_EMPTY_INIT_VALUE;
-Map(cstr_t, int) *highlight_unames;
+Map(cstr_t, int) highlight_unames = MAP_INIT;
static inline struct hl_group * HL_TABLE(void)
{
@@ -385,11 +385,6 @@ static int current_line_id = 0; // unique number for current line
static int syn_time_on = FALSE;
# define IF_SYN_TIME(p) (p)
-void syntax_init(void)
-{
- highlight_unames = map_new(cstr_t, int)();
-}
-
// Set the timeout used for syntax highlighting.
// Use NULL to reset, no timeout.
void syn_set_timeout(proftime_T *tm)
@@ -7119,7 +7114,7 @@ void free_highlight(void)
xfree(HL_TABLE()[i].sg_name_u);
}
ga_clear(&highlight_ga);
- map_free(cstr_t, int)(highlight_unames);
+ map_destroy(cstr_t, int)(&highlight_unames);
}
#endif
@@ -7505,7 +7500,7 @@ int syn_name2id_len(const char_u *name, size_t len)
// map_get(..., int) returns 0 when no key is present, which is
// the expected value for missing highlight group.
- return map_get(cstr_t, int)(highlight_unames, name_u);
+ return map_get(cstr_t, int)(&highlight_unames, name_u);
}
/// Lookup a highlight group name and return its attributes.
@@ -7609,7 +7604,7 @@ static int syn_add_group(char_u *name)
int id = highlight_ga.ga_len; // ID is index plus one
- map_put(cstr_t, int)(highlight_unames, name_up, id);
+ map_put(cstr_t, int)(&highlight_unames, name_up, id);
return id;
}
@@ -7620,7 +7615,7 @@ static void syn_unadd_group(void)
{
highlight_ga.ga_len--;
HlGroup *item = &HL_TABLE()[highlight_ga.ga_len];
- map_del(cstr_t, int)(highlight_unames, item->sg_name_u);
+ map_del(cstr_t, int)(&highlight_unames, item->sg_name_u);
xfree(item->sg_name);
xfree(item->sg_name_u);
}
diff --git a/src/nvim/terminal.c b/src/nvim/terminal.c
index 45419b8247..88dd9db6d1 100644
--- a/src/nvim/terminal.c
+++ b/src/nvim/terminal.c
@@ -76,7 +76,6 @@
#include "nvim/event/time.h"
#include "nvim/os/input.h"
#include "nvim/api/private/helpers.h"
-#include "nvim/api/private/handle.h"
typedef struct terminal_state {
VimState state;
diff --git a/src/nvim/window.c b/src/nvim/window.c
index fefbab822e..990064b33d 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -5,7 +5,6 @@
#include <inttypes.h>
#include <stdbool.h>
-#include "nvim/api/private/handle.h"
#include "nvim/api/private/helpers.h"
#include "nvim/vim.h"
#include "nvim/ascii.h"
@@ -3601,7 +3600,7 @@ static tabpage_T *alloc_tabpage(void)
static int last_tp_handle = 0;
tabpage_T *tp = xcalloc(1, sizeof(tabpage_T));
tp->handle = ++last_tp_handle;
- handle_register_tabpage(tp);
+ pmap_put(handle_T)(&tabpage_handles, tp->handle, tp);
// Init t: variables.
tp->tp_vars = tv_dict_alloc();
@@ -3616,7 +3615,7 @@ void free_tabpage(tabpage_T *tp)
{
int idx;
- handle_unregister_tabpage(tp);
+ pmap_del(handle_T)(&tabpage_handles, tp->handle);
diff_clear(tp);
for (idx = 0; idx < SNAP_COUNT; ++idx)
clear_snapshot(tp, idx);
@@ -4545,7 +4544,7 @@ static win_T *win_alloc(win_T *after, bool hidden)
win_T *new_wp = xcalloc(1, sizeof(win_T));
new_wp->handle = ++last_win_id;
- handle_register_window(new_wp);
+ pmap_put(handle_T)(&window_handles, new_wp->handle, new_wp);
grid_assign_handle(&new_wp->w_grid_alloc);
@@ -4616,7 +4615,7 @@ win_free (
int i;
wininfo_T *wip;
- handle_unregister_window(wp);
+ pmap_del(handle_T)(&window_handles, wp->handle);
clearFolding(wp);
/* reduce the reference count to the argument list. */