mirror of
https://github.com/neovim/neovim.git
synced 2025-09-17 08:48:16 +00:00
refactor(map): avoid duplicated khash_t types for values
This reduces the total number of khash_t instantiations from 22 to 8. Make the khash internal functions take the size of values as a runtime parameter. This is abstracted with typesafe Map containers which are still specialized for both key, value type. Introduce `Set(key)` type for when there is no value. Refactor shada.c to use Map/Set instead of khash directly. This requires `map_ref` operation to be more flexible. Return pointers to both key and value, plus an indicator for new_item. As a bonus, `map_key` is now redundant. Instead of Map(cstr_t, FileMarks), use a pointer map as the FileMarks struct is humongous. Make `event_strings` actually work like an intern pool instead of wtf it was doing before.
This commit is contained in:
@@ -4520,7 +4520,7 @@ bool garbage_collect(bool testing)
|
||||
// Channels
|
||||
{
|
||||
Channel *data;
|
||||
map_foreach_value(&channels, data, {
|
||||
pmap_foreach_value(&channels, data, {
|
||||
set_ref_in_callback_reader(&data->on_data, copyID, NULL, NULL);
|
||||
set_ref_in_callback_reader(&data->on_stderr, copyID, NULL, NULL);
|
||||
set_ref_in_callback(&data->on_exit, copyID, NULL, NULL);
|
||||
@@ -4530,7 +4530,7 @@ bool garbage_collect(bool testing)
|
||||
// Timers
|
||||
{
|
||||
timer_T *timer;
|
||||
map_foreach_value(&timers, timer, {
|
||||
pmap_foreach_value(&timers, timer, {
|
||||
set_ref_in_callback(&timer->callback, copyID, NULL, NULL);
|
||||
})
|
||||
}
|
||||
@@ -5986,7 +5986,7 @@ void add_timer_info_all(typval_T *rettv)
|
||||
{
|
||||
tv_list_alloc_ret(rettv, map_size(&timers));
|
||||
timer_T *timer;
|
||||
map_foreach_value(&timers, timer, {
|
||||
pmap_foreach_value(&timers, timer, {
|
||||
if (!timer->stopped || timer->refcount > 1) {
|
||||
add_timer_info(rettv, timer);
|
||||
}
|
||||
@@ -6084,7 +6084,7 @@ static void timer_close_cb(TimeWatcher *tw, void *data)
|
||||
timer_T *timer = (timer_T *)data;
|
||||
multiqueue_free(timer->tw.events);
|
||||
callback_free(&timer->callback);
|
||||
pmap_del(uint64_t)(&timers, (uint64_t)timer->timer_id);
|
||||
pmap_del(uint64_t)(&timers, (uint64_t)timer->timer_id, NULL);
|
||||
timer_decref(timer);
|
||||
}
|
||||
|
||||
@@ -6098,7 +6098,7 @@ static void timer_decref(timer_T *timer)
|
||||
void timer_stop_all(void)
|
||||
{
|
||||
timer_T *timer;
|
||||
map_foreach_value(&timers, timer, {
|
||||
pmap_foreach_value(&timers, timer, {
|
||||
timer_stop(timer);
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user