mirror of
https://github.com/neovim/neovim.git
synced 2025-09-12 14:28:18 +00:00
Merge pull request #15451 from bfredl/metamap
perf(map): get rid of unnecessary pointer indirections for maps.
This commit is contained in:
@@ -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);
|
|
||||||
}
|
|
@@ -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
|
|
||||||
|
|
@@ -9,7 +9,6 @@
|
|||||||
|
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
#include "nvim/api/vim.h"
|
#include "nvim/api/vim.h"
|
||||||
#include "nvim/msgpack_rpc/helpers.h"
|
#include "nvim/msgpack_rpc/helpers.h"
|
||||||
#include "nvim/lua/executor.h"
|
#include "nvim/lua/executor.h"
|
||||||
@@ -1725,7 +1724,7 @@ const char *describe_ns(NS ns_id)
|
|||||||
{
|
{
|
||||||
String name;
|
String name;
|
||||||
handle_T id;
|
handle_T id;
|
||||||
map_foreach(namespace_ids, name, id, {
|
map_foreach((&namespace_ids), name, id, {
|
||||||
if ((NS)id == ns_id && name.size) {
|
if ((NS)id == ns_id && name.size) {
|
||||||
return name.data;
|
return name.data;
|
||||||
}
|
}
|
||||||
|
@@ -101,6 +101,14 @@
|
|||||||
#define api_free_window(value)
|
#define api_free_window(value)
|
||||||
#define api_free_tabpage(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
|
/// Structure used for saving state for :try
|
||||||
///
|
///
|
||||||
/// Used when caller is supposed to be operating when other VimL code is being
|
/// Used when caller is supposed to be operating when other VimL code is being
|
||||||
|
@@ -37,24 +37,18 @@ typedef struct {
|
|||||||
bool wildmenu_active;
|
bool wildmenu_active;
|
||||||
} UIData;
|
} UIData;
|
||||||
|
|
||||||
static PMap(uint64_t) *connected_uis = NULL;
|
static PMap(uint64_t) connected_uis = MAP_INIT;
|
||||||
|
|
||||||
void remote_ui_init(void)
|
|
||||||
FUNC_API_NOEXPORT
|
|
||||||
{
|
|
||||||
connected_uis = pmap_new(uint64_t)();
|
|
||||||
}
|
|
||||||
|
|
||||||
void remote_ui_disconnect(uint64_t channel_id)
|
void remote_ui_disconnect(uint64_t channel_id)
|
||||||
FUNC_API_NOEXPORT
|
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) {
|
if (!ui) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
UIData *data = ui->data;
|
UIData *data = ui->data;
|
||||||
api_free_array(data->buffer); // Destroy pending screen updates.
|
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);
|
xfree(ui->data);
|
||||||
ui->data = NULL; // Flag UI as "stopped".
|
ui->data = NULL; // Flag UI as "stopped".
|
||||||
ui_detach_impl(ui, channel_id);
|
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,
|
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.
|
/// 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)
|
Dictionary options, Error *err)
|
||||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
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,
|
api_set_error(err, kErrorTypeException,
|
||||||
"UI already attached to channel: %" PRId64, channel_id);
|
"UI already attached to channel: %" PRId64, channel_id);
|
||||||
return;
|
return;
|
||||||
@@ -172,7 +166,7 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
|||||||
data->wildmenu_active = false;
|
data->wildmenu_active = false;
|
||||||
ui->data = data;
|
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);
|
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)
|
void nvim_ui_detach(uint64_t channel_id, Error *err)
|
||||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
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,
|
api_set_error(err, kErrorTypeException,
|
||||||
"UI not attached to channel: %" PRId64, channel_id);
|
"UI not attached to channel: %" PRId64, channel_id);
|
||||||
return;
|
return;
|
||||||
@@ -208,7 +202,7 @@ void nvim_ui_try_resize(uint64_t channel_id, Integer width,
|
|||||||
Integer height, Error *err)
|
Integer height, Error *err)
|
||||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
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,
|
api_set_error(err, kErrorTypeException,
|
||||||
"UI not attached to channel: %" PRId64, channel_id);
|
"UI not attached to channel: %" PRId64, channel_id);
|
||||||
return;
|
return;
|
||||||
@@ -220,7 +214,7 @@ void nvim_ui_try_resize(uint64_t channel_id, Integer width,
|
|||||||
return;
|
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->width = (int)width;
|
||||||
ui->height = (int)height;
|
ui->height = (int)height;
|
||||||
ui_refresh();
|
ui_refresh();
|
||||||
@@ -230,12 +224,12 @@ void nvim_ui_set_option(uint64_t channel_id, String name,
|
|||||||
Object value, Error *error)
|
Object value, Error *error)
|
||||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
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,
|
api_set_error(error, kErrorTypeException,
|
||||||
"UI not attached to channel: %" PRId64, channel_id);
|
"UI not attached to channel: %" PRId64, channel_id);
|
||||||
return;
|
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);
|
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)
|
Integer height, Error *err)
|
||||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY
|
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,
|
api_set_error(err, kErrorTypeException,
|
||||||
"UI not attached to channel: %" PRId64, channel_id);
|
"UI not attached to channel: %" PRId64, channel_id);
|
||||||
return;
|
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)
|
void nvim_ui_pum_set_height(uint64_t channel_id, Integer height, Error *err)
|
||||||
FUNC_API_SINCE(6) FUNC_API_REMOTE_ONLY
|
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,
|
api_set_error(err, kErrorTypeException,
|
||||||
"UI not attached to channel: %" PRId64, channel_id);
|
"UI not attached to channel: %" PRId64, channel_id);
|
||||||
return;
|
return;
|
||||||
@@ -339,7 +333,7 @@ void nvim_ui_pum_set_height(uint64_t channel_id, Integer height, Error *err)
|
|||||||
return;
|
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]) {
|
if (!ui->ui_ext[kUIPopupmenu]) {
|
||||||
api_set_error(err, kErrorTypeValidation,
|
api_set_error(err, kErrorTypeValidation,
|
||||||
"It must support the ext_popupmenu option");
|
"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)
|
Float row, Float col, Error *err)
|
||||||
FUNC_API_SINCE(7) FUNC_API_REMOTE_ONLY
|
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,
|
api_set_error(err, kErrorTypeException,
|
||||||
"UI not attached to channel: %" PRId64, channel_id);
|
"UI not attached to channel: %" PRId64, channel_id);
|
||||||
return;
|
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]) {
|
if (!ui->ui_ext[kUIPopupmenu]) {
|
||||||
api_set_error(err, kErrorTypeValidation,
|
api_set_error(err, kErrorTypeValidation,
|
||||||
"UI must support the ext_popupmenu option");
|
"UI must support the ext_popupmenu option");
|
||||||
|
@@ -58,22 +58,16 @@
|
|||||||
# include "api/vim.c.generated.h"
|
# include "api/vim.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void api_vim_init(void)
|
|
||||||
FUNC_API_NOEXPORT
|
|
||||||
{
|
|
||||||
namespace_ids = map_new(String, handle_T)();
|
|
||||||
}
|
|
||||||
|
|
||||||
void api_vim_free_all_mem(void)
|
void api_vim_free_all_mem(void)
|
||||||
FUNC_API_NOEXPORT
|
FUNC_API_NOEXPORT
|
||||||
{
|
{
|
||||||
String name;
|
String name;
|
||||||
handle_T id;
|
handle_T id;
|
||||||
map_foreach(namespace_ids, name, id, {
|
map_foreach((&namespace_ids), name, id, {
|
||||||
(void)id;
|
(void)id;
|
||||||
xfree(name.data);
|
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
|
/// 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)
|
Integer nvim_create_namespace(String name)
|
||||||
FUNC_API_SINCE(5)
|
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) {
|
if (id > 0) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
id = next_namespace_id++;
|
id = next_namespace_id++;
|
||||||
if (name.size > 0) {
|
if (name.size > 0) {
|
||||||
String name_alloc = copy_string(name);
|
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;
|
return (Integer)id;
|
||||||
}
|
}
|
||||||
@@ -1590,7 +1584,7 @@ Dictionary nvim_get_namespaces(void)
|
|||||||
String name;
|
String name;
|
||||||
handle_T id;
|
handle_T id;
|
||||||
|
|
||||||
map_foreach(namespace_ids, name, id, {
|
map_foreach((&namespace_ids), name, id, {
|
||||||
PUT(retval, name.data, INTEGER_OBJ(id));
|
PUT(retval, name.data, INTEGER_OBJ(id));
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/map.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);
|
EXTERN handle_T next_namespace_id INIT(= 1);
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
#include "nvim/autocmd.h"
|
#include "nvim/autocmd.h"
|
||||||
|
|
||||||
#include "nvim/api/private/handle.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/buffer.h"
|
#include "nvim/buffer.h"
|
||||||
#include "nvim/charset.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.
|
block_autocmds(); // We don't want BufEnter/WinEnter autocommands.
|
||||||
if (need_append) {
|
if (need_append) {
|
||||||
win_append(lastwin, aucmd_win);
|
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);
|
win_config_float(aucmd_win, aucmd_win->w_float_config);
|
||||||
}
|
}
|
||||||
// Prevent chdir() call in win_enter_ext(), through do_autochdir()
|
// Prevent chdir() call in win_enter_ext(), through do_autochdir()
|
||||||
@@ -1191,7 +1191,7 @@ void aucmd_restbuf(aco_save_T *aco)
|
|||||||
win_found:
|
win_found:
|
||||||
|
|
||||||
win_remove(curwin, NULL);
|
win_remove(curwin, NULL);
|
||||||
handle_unregister_window(curwin);
|
pmap_del(handle_T)(&window_handles, curwin->handle);
|
||||||
if (curwin->w_grid_alloc.chars != NULL) {
|
if (curwin->w_grid_alloc.chars != NULL) {
|
||||||
ui_comp_remove_grid(&curwin->w_grid_alloc);
|
ui_comp_remove_grid(&curwin->w_grid_alloc);
|
||||||
ui_call_win_hide(curwin->w_grid_alloc.handle);
|
ui_call_win_hide(curwin->w_grid_alloc.handle);
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/api/vim.h"
|
#include "nvim/api/vim.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
@@ -757,7 +756,7 @@ void buf_freeall(buf_T *buf, int flags)
|
|||||||
*/
|
*/
|
||||||
static void free_buffer(buf_T *buf)
|
static void free_buffer(buf_T *buf)
|
||||||
{
|
{
|
||||||
handle_unregister_buffer(buf);
|
pmap_del(handle_T)(&buffer_handles, buf->b_fnum);
|
||||||
buf_free_count++;
|
buf_free_count++;
|
||||||
// b:changedtick uses an item in buf_T.
|
// b:changedtick uses an item in buf_T.
|
||||||
free_buffer_stuff(buf, kBffClearWinInfo);
|
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;
|
lastbuf = buf;
|
||||||
|
|
||||||
buf->b_fnum = top_file_num++;
|
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)
|
if (top_file_num < 0) { // wrap around (may cause duplicates)
|
||||||
EMSG(_("W14: Warning: List of file names overflow"));
|
EMSG(_("W14: Warning: List of file names overflow"));
|
||||||
if (emsg_silent == 0) {
|
if (emsg_silent == 0) {
|
||||||
|
@@ -863,8 +863,8 @@ struct file_buffer {
|
|||||||
int b_mapped_ctrl_c; // modes where CTRL-C is mapped
|
int b_mapped_ctrl_c; // modes where CTRL-C is mapped
|
||||||
|
|
||||||
MarkTree b_marktree[1];
|
MarkTree b_marktree[1];
|
||||||
Map(uint64_t, ExtmarkItem) *b_extmark_index;
|
Map(uint64_t, ExtmarkItem) b_extmark_index[1];
|
||||||
Map(uint64_t, ExtmarkNs) *b_extmark_ns; // extmark namespaces
|
Map(uint64_t, ExtmarkNs) b_extmark_ns[1]; // extmark namespaces
|
||||||
|
|
||||||
// array of channel_id:s which have asked to receive updates for this
|
// array of channel_id:s which have asked to receive updates for this
|
||||||
// buffer.
|
// buffer.
|
||||||
|
@@ -13,12 +13,7 @@
|
|||||||
# include "decoration.c.generated.h"
|
# include "decoration.c.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static PMap(uint64_t) *hl_decors;
|
static PMap(uint64_t) hl_decors;
|
||||||
|
|
||||||
void decor_init(void)
|
|
||||||
{
|
|
||||||
hl_decors = pmap_new(uint64_t)();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Add highlighting to a buffer, bounded by two cursor positions,
|
/// Add highlighting to a buffer, bounded by two cursor positions,
|
||||||
/// with an offset.
|
/// with an offset.
|
||||||
@@ -77,7 +72,7 @@ void bufhl_add_hl_pos_offset(buf_T *buf,
|
|||||||
Decoration *decor_hl(int hl_id)
|
Decoration *decor_hl(int hl_id)
|
||||||
{
|
{
|
||||||
assert(hl_id > 0);
|
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);
|
(uint64_t)hl_id, true);
|
||||||
if (*dp) {
|
if (*dp) {
|
||||||
return *dp;
|
return *dp;
|
||||||
@@ -150,7 +145,7 @@ bool decor_redraw_reset(buf_T *buf, DecorState *state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
kv_size(state->active) = 0;
|
kv_size(state->active) = 0;
|
||||||
return buf->b_extmark_index;
|
return map_size(buf->b_extmark_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7331,7 +7331,7 @@ void add_timer_info(typval_T *rettv, timer_T *timer)
|
|||||||
|
|
||||||
void add_timer_info_all(typval_T *rettv)
|
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;
|
timer_T *timer;
|
||||||
map_foreach_value(timers, timer, {
|
map_foreach_value(timers, timer, {
|
||||||
if (!timer->stopped) {
|
if (!timer->stopped) {
|
||||||
|
@@ -48,20 +48,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ExtmarkNs *buf_ns_ref(buf_T *buf, uint64_t ns_id, bool put) {
|
static ExtmarkNs *buf_ns_ref(buf_T *buf, uint64_t ns_id, bool put) {
|
||||||
if (!buf->b_extmark_ns) {
|
return map_ref(uint64_t, ExtmarkNs)(buf->b_extmark_ns, ns_id, put);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -195,7 +182,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
|
|||||||
int l_row, colnr_T l_col,
|
int l_row, colnr_T l_col,
|
||||||
int u_row, colnr_T u_col)
|
int u_row, colnr_T u_col)
|
||||||
{
|
{
|
||||||
if (!buf->b_extmark_ns) {
|
if (!map_size(buf->b_extmark_ns)) {
|
||||||
return false;
|
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.
|
// 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;
|
typedef struct { Decoration *decor; int row1; } DecorItem;
|
||||||
static kvec_t(DecorItem) decors;
|
static kvec_t(DecorItem) decors;
|
||||||
if (delete_set == NULL) {
|
|
||||||
delete_set = map_new(uint64_t, ssize_t)();
|
|
||||||
}
|
|
||||||
|
|
||||||
MarkTreeIter itr[1] = { 0 };
|
MarkTreeIter itr[1] = { 0 };
|
||||||
marktree_itr_get(buf->b_marktree, l_row, l_col, itr);
|
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)) {
|
|| (mark.row == u_row && mark.col > u_col)) {
|
||||||
break;
|
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);
|
false);
|
||||||
if (del_status) {
|
if (del_status) {
|
||||||
marktree_del_itr(buf->b_marktree, itr, false);
|
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_redraw(buf, it.row1, mark.row, it.decor);
|
||||||
decor_free(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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +245,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
|
|||||||
kv_push(decors,
|
kv_push(decors,
|
||||||
((DecorItem) { .decor = item.decor, .row1 = mark.row }));
|
((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) {
|
} else if (item.decor) {
|
||||||
decor_redraw(buf, mark.row, mark.row, item.decor);
|
decor_redraw(buf, mark.row, mark.row, item.decor);
|
||||||
decor_free(item.decor);
|
decor_free(item.decor);
|
||||||
@@ -276,7 +260,7 @@ bool extmark_clear(buf_T *buf, uint64_t ns_id,
|
|||||||
}
|
}
|
||||||
uint64_t id;
|
uint64_t id;
|
||||||
ssize_t decor_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);
|
mtpos_t pos = marktree_lookup(buf->b_marktree, id, itr);
|
||||||
assert(itr->node);
|
assert(itr->node);
|
||||||
marktree_del_itr(buf->b_marktree, itr, false);
|
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);
|
decor_free(it.decor);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
map_clear(uint64_t, ssize_t)(delete_set);
|
map_clear(uint64_t, ssize_t)(&delete_set);
|
||||||
kv_size(decors) = 0;
|
kv_size(decors) = 0;
|
||||||
return marks_cleared;
|
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
|
// free extmarks from the buffer
|
||||||
void extmark_free_all(buf_T *buf)
|
void extmark_free_all(buf_T *buf)
|
||||||
{
|
{
|
||||||
if (!buf->b_extmark_ns) {
|
if (!map_size(buf->b_extmark_ns)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,17 +379,17 @@ void extmark_free_all(buf_T *buf)
|
|||||||
|
|
||||||
map_foreach(buf->b_extmark_ns, id, ns, {
|
map_foreach(buf->b_extmark_ns, id, ns, {
|
||||||
(void)id;
|
(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);
|
map_destroy(uint64_t, ExtmarkNs)(buf->b_extmark_ns);
|
||||||
buf->b_extmark_ns = NULL;
|
map_init(uint64_t, ExtmarkNs, buf->b_extmark_ns);
|
||||||
|
|
||||||
map_foreach(buf->b_extmark_index, id, item, {
|
map_foreach(buf->b_extmark_index, id, item, {
|
||||||
(void)id;
|
(void)id;
|
||||||
decor_free(item.decor);
|
decor_free(item.decor);
|
||||||
});
|
});
|
||||||
map_free(uint64_t, ExtmarkItem)(buf->b_extmark_index);
|
map_destroy(uint64_t, ExtmarkItem)(buf->b_extmark_index);
|
||||||
buf->b_extmark_index = NULL;
|
map_init(uint64_t, ExtmarkItem, buf->b_extmark_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/api/private/handle.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/fileio.h"
|
#include "nvim/fileio.h"
|
||||||
#include "nvim/buffer.h"
|
#include "nvim/buffer.h"
|
||||||
|
@@ -52,7 +52,6 @@
|
|||||||
#include "nvim/os/input.h"
|
#include "nvim/os/input.h"
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/os/fileio.h"
|
#include "nvim/os/fileio.h"
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
|
|
||||||
|
|
||||||
/// Index in scriptin
|
/// Index in scriptin
|
||||||
|
@@ -25,22 +25,16 @@ static bool hlstate_active = false;
|
|||||||
|
|
||||||
static kvec_t(HlEntry) attr_entries = KV_INITIAL_VALUE;
|
static kvec_t(HlEntry) attr_entries = KV_INITIAL_VALUE;
|
||||||
|
|
||||||
static Map(HlEntry, int) *attr_entry_ids;
|
static Map(HlEntry, int) attr_entry_ids = MAP_INIT;
|
||||||
static Map(int, int) *combine_attr_entries;
|
static Map(int, int) combine_attr_entries = MAP_INIT;
|
||||||
static Map(int, int) *blend_attr_entries;
|
static Map(int, int) blend_attr_entries = MAP_INIT;
|
||||||
static Map(int, int) *blendthrough_attr_entries;
|
static Map(int, int) blendthrough_attr_entries = MAP_INIT;
|
||||||
|
|
||||||
/// highlight entries private to a namespace
|
/// highlight entries private to a namespace
|
||||||
static Map(ColorKey, ColorItem) *ns_hl;
|
static Map(ColorKey, ColorItem) ns_hl;
|
||||||
|
|
||||||
void highlight_init(void)
|
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:
|
// index 0 is no attribute, add dummy entry:
|
||||||
kv_push(attr_entries, ((HlEntry){ .attr = HLATTRS_INIT, .kind = kHlUnknown,
|
kv_push(attr_entries, ((HlEntry){ .attr = HLATTRS_INIT, .kind = kHlUnknown,
|
||||||
.id1 = 0, .id2 = 0 }));
|
.id1 = 0, .id2 = 0 }));
|
||||||
@@ -71,7 +65,7 @@ static int get_attr_entry(HlEntry entry)
|
|||||||
entry.id2 = 0;
|
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) {
|
if (id > 0) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -104,7 +98,7 @@ static int get_attr_entry(HlEntry entry)
|
|||||||
id = (int)next_id;
|
id = (int)next_id;
|
||||||
kv_push(attr_entries, entry);
|
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);
|
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);
|
DecorProvider *p = get_decor_provider(ns_id, true);
|
||||||
if ((attrs.rgb_ae_attr & HL_DEFAULT)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
int attr_id = link_id > 0 ? -1 : hl_get_syn_attr(ns_id, hl_id, attrs);
|
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,
|
.link_id = link_id,
|
||||||
.version = p->hl_valid,
|
.version = p->hl_valid,
|
||||||
.is_default = (attrs.rgb_ae_attr & HL_DEFAULT) };
|
.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)
|
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);
|
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?
|
// TODO(bfredl): map_ref true even this?
|
||||||
bool valid_cache = it.version >= p->hl_valid;
|
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.attr_id = fallback ? -1 : hl_get_syn_attr((int)ns_id, hl_id, attrs);
|
||||||
it.version = p->hl_valid-tmp;
|
it.version = p->hl_valid-tmp;
|
||||||
it.is_default = attrs.rgb_ae_attr & HL_DEFAULT;
|
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) {
|
if (it.is_default && nodefault) {
|
||||||
@@ -395,28 +389,28 @@ void clear_hl_tables(bool reinit)
|
|||||||
{
|
{
|
||||||
if (reinit) {
|
if (reinit) {
|
||||||
kv_size(attr_entries) = 1;
|
kv_size(attr_entries) = 1;
|
||||||
map_clear(HlEntry, int)(attr_entry_ids);
|
map_clear(HlEntry, int)(&attr_entry_ids);
|
||||||
map_clear(int, int)(combine_attr_entries);
|
map_clear(int, int)(&combine_attr_entries);
|
||||||
map_clear(int, int)(blend_attr_entries);
|
map_clear(int, int)(&blend_attr_entries);
|
||||||
map_clear(int, int)(blendthrough_attr_entries);
|
map_clear(int, int)(&blendthrough_attr_entries);
|
||||||
memset(highlight_attr_last, -1, sizeof(highlight_attr_last));
|
memset(highlight_attr_last, -1, sizeof(highlight_attr_last));
|
||||||
highlight_attr_set_all();
|
highlight_attr_set_all();
|
||||||
highlight_changed();
|
highlight_changed();
|
||||||
screen_invalidate_highlights();
|
screen_invalidate_highlights();
|
||||||
} else {
|
} else {
|
||||||
kv_destroy(attr_entries);
|
kv_destroy(attr_entries);
|
||||||
map_free(HlEntry, int)(attr_entry_ids);
|
map_destroy(HlEntry, int)(&attr_entry_ids);
|
||||||
map_free(int, int)(combine_attr_entries);
|
map_destroy(int, int)(&combine_attr_entries);
|
||||||
map_free(int, int)(blend_attr_entries);
|
map_destroy(int, int)(&blend_attr_entries);
|
||||||
map_free(int, int)(blendthrough_attr_entries);
|
map_destroy(int, int)(&blendthrough_attr_entries);
|
||||||
map_free(ColorKey, ColorItem)(ns_hl);
|
map_destroy(ColorKey, ColorItem)(&ns_hl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void hl_invalidate_blends(void)
|
void hl_invalidate_blends(void)
|
||||||
{
|
{
|
||||||
map_clear(int, int)(blend_attr_entries);
|
map_clear(int, int)(&blend_attr_entries);
|
||||||
map_clear(int, int)(blendthrough_attr_entries);
|
map_clear(int, int)(&blendthrough_attr_entries);
|
||||||
highlight_changed();
|
highlight_changed();
|
||||||
update_window_hl(curwin, true);
|
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.
|
// TODO(bfredl): could use a struct for clearer intent.
|
||||||
int combine_tag = (char_attr << 16) + prim_attr;
|
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) {
|
if (id > 0) {
|
||||||
return id;
|
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,
|
id = get_attr_entry((HlEntry){ .attr = new_en, .kind = kHlCombine,
|
||||||
.id1 = char_attr, .id2 = prim_attr });
|
.id1 = char_attr, .id2 = prim_attr });
|
||||||
if (id > 0) {
|
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;
|
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;
|
int combine_tag = (back_attr << 16) + front_attr;
|
||||||
Map(int, int) *map = (*through
|
Map(int, int) *map = (*through
|
||||||
? blendthrough_attr_entries
|
? &blendthrough_attr_entries
|
||||||
: blend_attr_entries);
|
: &blend_attr_entries);
|
||||||
int id = map_get(int, int)(map, combine_tag);
|
int id = map_get(int, int)(map, combine_tag);
|
||||||
if (id > 0) {
|
if (id > 0) {
|
||||||
return id;
|
return id;
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
#include "nvim/func_attr.h"
|
#include "nvim/func_attr.h"
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
#include "nvim/api/vim.h"
|
#include "nvim/api/vim.h"
|
||||||
#include "nvim/msgpack_rpc/channel.h"
|
#include "nvim/msgpack_rpc/channel.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
#include "tree_sitter/api.h"
|
#include "tree_sitter/api.h"
|
||||||
|
|
||||||
#include "nvim/lua/treesitter.h"
|
#include "nvim/lua/treesitter.h"
|
||||||
#include "nvim/api/private/handle.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/memline.h"
|
#include "nvim/memline.h"
|
||||||
#include "nvim/buffer.h"
|
#include "nvim/buffer.h"
|
||||||
|
|
||||||
|
@@ -78,7 +78,6 @@
|
|||||||
#include "nvim/api/ui.h"
|
#include "nvim/api/ui.h"
|
||||||
#include "nvim/api/private/defs.h"
|
#include "nvim/api/private/defs.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
#include "nvim/api/private/dispatch.h"
|
#include "nvim/api/private/dispatch.h"
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
# include "nvim/os/pty_process_unix.h"
|
# include "nvim/os/pty_process_unix.h"
|
||||||
@@ -126,8 +125,6 @@ void event_init(void)
|
|||||||
signal_init();
|
signal_init();
|
||||||
// finish mspgack-rpc initialization
|
// finish mspgack-rpc initialization
|
||||||
channel_init();
|
channel_init();
|
||||||
remote_ui_init();
|
|
||||||
api_vim_init();
|
|
||||||
terminal_init();
|
terminal_init();
|
||||||
ui_init();
|
ui_init();
|
||||||
}
|
}
|
||||||
@@ -160,13 +157,10 @@ void early_init(mparm_T *paramp)
|
|||||||
{
|
{
|
||||||
env_init();
|
env_init();
|
||||||
fs_init();
|
fs_init();
|
||||||
handle_init();
|
|
||||||
decor_init();
|
|
||||||
eval_init(); // init global variables
|
eval_init(); // init global variables
|
||||||
init_path(argv0 ? argv0 : "nvim");
|
init_path(argv0 ? argv0 : "nvim");
|
||||||
init_normal_cmds(); // Init the table of Normal mode commands.
|
init_normal_cmds(); // Init the table of Normal mode commands.
|
||||||
highlight_init();
|
highlight_init();
|
||||||
syntax_init();
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
OSVERSIONINFO ovi;
|
OSVERSIONINFO ovi;
|
||||||
|
@@ -56,54 +56,59 @@
|
|||||||
\
|
\
|
||||||
Map(T, U) *map_##T##_##U##_new() \
|
Map(T, U) *map_##T##_##U##_new() \
|
||||||
{ \
|
{ \
|
||||||
Map(T, U) *rv = xmalloc(sizeof(Map(T, U))); \
|
Map(T, U) *rv = xcalloc(1, sizeof(Map(T, U))); \
|
||||||
rv->table = kh_init(T##_##U##_map); \
|
/* khash_t table member is zero-initialized */ \
|
||||||
return rv; \
|
return rv; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
void map_##T##_##U##_free(Map(T, U) *map) \
|
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); \
|
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) \
|
U map_##T##_##U##_get(Map(T, U) *map, T key) \
|
||||||
{ \
|
{ \
|
||||||
khiter_t k; \
|
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 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) \
|
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) \
|
T map_##T##_##U##_key(Map(T, U) *map, T key) \
|
||||||
{ \
|
{ \
|
||||||
khiter_t k; \
|
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(). */ \
|
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) \
|
U map_##T##_##U##_put(Map(T, U) *map, T key, U value) \
|
||||||
{ \
|
{ \
|
||||||
int ret; \
|
int ret; \
|
||||||
U rv = INITIALIZER(T, U); \
|
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) { \
|
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; \
|
return rv; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
@@ -112,18 +117,18 @@
|
|||||||
int ret; \
|
int ret; \
|
||||||
khiter_t k; \
|
khiter_t k; \
|
||||||
if (put) { \
|
if (put) { \
|
||||||
k = kh_put(T##_##U##_map, map->table, key, &ret); \
|
k = kh_put(T##_##U##_map, &map->table, key, &ret); \
|
||||||
if (ret) { \
|
if (ret) { \
|
||||||
kh_val(map->table, k) = INITIALIZER(T, U); \
|
kh_val(&map->table, k) = INITIALIZER(T, U); \
|
||||||
} \
|
} \
|
||||||
} else { \
|
} else { \
|
||||||
k = kh_get(T##_##U##_map, map->table, key); \
|
k = kh_get(T##_##U##_map, &map->table, key); \
|
||||||
if (k == kh_end(map->table)) { \
|
if (k == kh_end(&map->table)) { \
|
||||||
return NULL; \
|
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) \
|
U map_##T##_##U##_del(Map(T, U) *map, T key) \
|
||||||
@@ -131,9 +136,9 @@
|
|||||||
U rv = INITIALIZER(T, U); \
|
U rv = INITIALIZER(T, U); \
|
||||||
khiter_t k; \
|
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)) { \
|
||||||
rv = kh_val(map->table, k); \
|
rv = kh_val(&map->table, k); \
|
||||||
kh_del(T##_##U##_map, map->table, k); \
|
kh_del(T##_##U##_map, &map->table, k); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
return rv; \
|
return rv; \
|
||||||
@@ -141,7 +146,7 @@
|
|||||||
\
|
\
|
||||||
void map_##T##_##U##_clear(Map(T, U) *map) \
|
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)
|
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, ptr_t, DEFAULT_INITIALIZER)
|
||||||
MAP_IMPL(uint64_t, ssize_t, SSIZE_INITIALIZER)
|
MAP_IMPL(uint64_t, ssize_t, SSIZE_INITIALIZER)
|
||||||
MAP_IMPL(uint64_t, uint64_t, DEFAULT_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)
|
MAP_IMPL(uint64_t, ExtmarkNs, EXTMARK_NS_INITIALIZER)
|
||||||
#define EXTMARK_ITEM_INITIALIZER { 0, 0, NULL }
|
#define EXTMARK_ITEM_INITIALIZER { 0, 0, NULL }
|
||||||
MAP_IMPL(uint64_t, ExtmarkItem, EXTMARK_ITEM_INITIALIZER)
|
MAP_IMPL(uint64_t, ExtmarkItem, EXTMARK_ITEM_INITIALIZER)
|
||||||
|
@@ -18,11 +18,12 @@
|
|||||||
KHASH_DECLARE(T##_##U##_map, T, U) \
|
KHASH_DECLARE(T##_##U##_map, T, U) \
|
||||||
\
|
\
|
||||||
typedef struct { \
|
typedef struct { \
|
||||||
khash_t(T##_##U##_map) *table; \
|
khash_t(T##_##U##_map) table; \
|
||||||
} Map(T, U); \
|
} Map(T, U); \
|
||||||
\
|
\
|
||||||
Map(T, U) *map_##T##_##U##_new(void); \
|
Map(T, U) *map_##T##_##U##_new(void); \
|
||||||
void map_##T##_##U##_free(Map(T, U) *map); \
|
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); \
|
U map_##T##_##U##_get(Map(T, U) *map, T key); \
|
||||||
bool map_##T##_##U##_has(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); \
|
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
|
// NB: this is the only way to define a struct both containing and contained
|
||||||
// in a map...
|
// in a map...
|
||||||
typedef struct ExtmarkNs { // For namespacing extmarks
|
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
|
uint64_t free_id; // For automatically assigning id's
|
||||||
} ExtmarkNs;
|
} ExtmarkNs;
|
||||||
|
|
||||||
@@ -58,8 +59,12 @@ MAP_DECLS(String, handle_T)
|
|||||||
|
|
||||||
MAP_DECLS(ColorKey, ColorItem)
|
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_new(T, U) map_##T##_##U##_new
|
||||||
#define map_free(T, U) map_##T##_##U##_free
|
#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_get(T, U) map_##T##_##U##_get
|
||||||
#define map_has(T, U) map_##T##_##U##_has
|
#define map_has(T, U) map_##T##_##U##_has
|
||||||
#define map_key(T, U) map_##T##_##U##_key
|
#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_del(T, U) map_##T##_##U##_del
|
||||||
#define map_clear(T, U) map_##T##_##U##_clear
|
#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_new(T) map_new(T, ptr_t)
|
||||||
#define pmap_free(T) map_free(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_get(T) map_get(T, ptr_t)
|
||||||
#define pmap_has(T) map_has(T, ptr_t)
|
#define pmap_has(T) map_has(T, ptr_t)
|
||||||
#define pmap_key(T) map_key(T, ptr_t)
|
#define pmap_key(T) map_key(T, ptr_t)
|
||||||
@@ -80,12 +86,13 @@ MAP_DECLS(ColorKey, ColorItem)
|
|||||||
/// @see pmap_del2
|
/// @see pmap_del2
|
||||||
#define pmap_del(T) map_del(T, ptr_t)
|
#define pmap_del(T) map_del(T, ptr_t)
|
||||||
#define pmap_clear(T) map_clear(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) \
|
#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) \
|
#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);
|
void pmap_del2(PMap(cstr_t) *map, const char *key);
|
||||||
|
|
||||||
|
@@ -250,7 +250,6 @@ void marktree_put_key(MarkTree *b, int row, int col, uint64_t id)
|
|||||||
|
|
||||||
if (!b->root) {
|
if (!b->root) {
|
||||||
b->root = (mtnode_t *)xcalloc(1, ILEN);
|
b->root = (mtnode_t *)xcalloc(1, ILEN);
|
||||||
b->id2node = pmap_new(uint64_t)();
|
|
||||||
b->n_nodes++;
|
b->n_nodes++;
|
||||||
}
|
}
|
||||||
mtnode_t *r, *s;
|
mtnode_t *r, *s;
|
||||||
@@ -547,9 +546,9 @@ void marktree_clear(MarkTree *b)
|
|||||||
marktree_free_node(b->root);
|
marktree_free_node(b->root);
|
||||||
b->root = NULL;
|
b->root = NULL;
|
||||||
}
|
}
|
||||||
if (b->id2node) {
|
if (b->id2node->table.keys) {
|
||||||
pmap_free(uint64_t)(b->id2node);
|
pmap_destroy(uint64_t)(b->id2node);
|
||||||
b->id2node = NULL;
|
pmap_init(uint64_t, b->id2node);
|
||||||
}
|
}
|
||||||
b->n_keys = 0;
|
b->n_keys = 0;
|
||||||
b->n_nodes = 0;
|
b->n_nodes = 0;
|
||||||
|
@@ -63,7 +63,7 @@ typedef struct {
|
|||||||
uint64_t next_id;
|
uint64_t next_id;
|
||||||
// TODO(bfredl): the pointer to node could be part of the larger
|
// TODO(bfredl): the pointer to node could be part of the larger
|
||||||
// Map(uint64_t, ExtmarkItem) essentially;
|
// Map(uint64_t, ExtmarkItem) essentially;
|
||||||
PMap(uint64_t) *id2node;
|
PMap(uint64_t) id2node[1];
|
||||||
} MarkTree;
|
} MarkTree;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/os_unix.h"
|
#include "nvim/os_unix.h"
|
||||||
|
@@ -91,7 +91,7 @@ typedef struct hl_group {
|
|||||||
|
|
||||||
// builtin |highlight-groups|
|
// builtin |highlight-groups|
|
||||||
static garray_T highlight_ga = GA_EMPTY_INIT_VALUE;
|
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)
|
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;
|
static int syn_time_on = FALSE;
|
||||||
# define IF_SYN_TIME(p) (p)
|
# define IF_SYN_TIME(p) (p)
|
||||||
|
|
||||||
void syntax_init(void)
|
|
||||||
{
|
|
||||||
highlight_unames = map_new(cstr_t, int)();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the timeout used for syntax highlighting.
|
// Set the timeout used for syntax highlighting.
|
||||||
// Use NULL to reset, no timeout.
|
// Use NULL to reset, no timeout.
|
||||||
void syn_set_timeout(proftime_T *tm)
|
void syn_set_timeout(proftime_T *tm)
|
||||||
@@ -7119,7 +7114,7 @@ void free_highlight(void)
|
|||||||
xfree(HL_TABLE()[i].sg_name_u);
|
xfree(HL_TABLE()[i].sg_name_u);
|
||||||
}
|
}
|
||||||
ga_clear(&highlight_ga);
|
ga_clear(&highlight_ga);
|
||||||
map_free(cstr_t, int)(highlight_unames);
|
map_destroy(cstr_t, int)(&highlight_unames);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#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
|
// map_get(..., int) returns 0 when no key is present, which is
|
||||||
// the expected value for missing highlight group.
|
// 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.
|
/// 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
|
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;
|
return id;
|
||||||
}
|
}
|
||||||
@@ -7620,7 +7615,7 @@ static void syn_unadd_group(void)
|
|||||||
{
|
{
|
||||||
highlight_ga.ga_len--;
|
highlight_ga.ga_len--;
|
||||||
HlGroup *item = &HL_TABLE()[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);
|
||||||
xfree(item->sg_name_u);
|
xfree(item->sg_name_u);
|
||||||
}
|
}
|
||||||
|
@@ -76,7 +76,6 @@
|
|||||||
#include "nvim/event/time.h"
|
#include "nvim/event/time.h"
|
||||||
#include "nvim/os/input.h"
|
#include "nvim/os/input.h"
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
|
|
||||||
typedef struct terminal_state {
|
typedef struct terminal_state {
|
||||||
VimState state;
|
VimState state;
|
||||||
|
@@ -5,7 +5,6 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "nvim/api/private/handle.h"
|
|
||||||
#include "nvim/api/private/helpers.h"
|
#include "nvim/api/private/helpers.h"
|
||||||
#include "nvim/vim.h"
|
#include "nvim/vim.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
@@ -3601,7 +3600,7 @@ static tabpage_T *alloc_tabpage(void)
|
|||||||
static int last_tp_handle = 0;
|
static int last_tp_handle = 0;
|
||||||
tabpage_T *tp = xcalloc(1, sizeof(tabpage_T));
|
tabpage_T *tp = xcalloc(1, sizeof(tabpage_T));
|
||||||
tp->handle = ++last_tp_handle;
|
tp->handle = ++last_tp_handle;
|
||||||
handle_register_tabpage(tp);
|
pmap_put(handle_T)(&tabpage_handles, tp->handle, tp);
|
||||||
|
|
||||||
// Init t: variables.
|
// Init t: variables.
|
||||||
tp->tp_vars = tv_dict_alloc();
|
tp->tp_vars = tv_dict_alloc();
|
||||||
@@ -3616,7 +3615,7 @@ void free_tabpage(tabpage_T *tp)
|
|||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
handle_unregister_tabpage(tp);
|
pmap_del(handle_T)(&tabpage_handles, tp->handle);
|
||||||
diff_clear(tp);
|
diff_clear(tp);
|
||||||
for (idx = 0; idx < SNAP_COUNT; ++idx)
|
for (idx = 0; idx < SNAP_COUNT; ++idx)
|
||||||
clear_snapshot(tp, 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));
|
win_T *new_wp = xcalloc(1, sizeof(win_T));
|
||||||
|
|
||||||
new_wp->handle = ++last_win_id;
|
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);
|
grid_assign_handle(&new_wp->w_grid_alloc);
|
||||||
|
|
||||||
@@ -4616,7 +4615,7 @@ win_free (
|
|||||||
int i;
|
int i;
|
||||||
wininfo_T *wip;
|
wininfo_T *wip;
|
||||||
|
|
||||||
handle_unregister_window(wp);
|
pmap_del(handle_T)(&window_handles, wp->handle);
|
||||||
clearFolding(wp);
|
clearFolding(wp);
|
||||||
|
|
||||||
/* reduce the reference count to the argument list. */
|
/* reduce the reference count to the argument list. */
|
||||||
|
Reference in New Issue
Block a user