mirror of
https://github.com/neovim/neovim.git
synced 2025-09-29 22:48:34 +00:00
refactor(marktree): embed the keymap in the MarkTree struct
This commit is contained in:
@@ -77,6 +77,7 @@ MAP_DECLS(ColorKey, ColorItem)
|
|||||||
|
|
||||||
#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)
|
||||||
@@ -85,6 +86,7 @@ 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)
|
||||||
|
@@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user