aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDaniel Hahler <git@thequod.de>2019-11-30 02:06:16 +0100
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2021-03-30 21:55:51 -0400
commitd6cac809b009e7066c8761b1466fe08378146d22 (patch)
tree36a3c453ce3910270c3a6d68441ea0b49e5c068c /src
parentaca002e7d5ac5e85c8d3e3402afd2b0b5aff0c0c (diff)
downloadrneovim-d6cac809b009e7066c8761b1466fe08378146d22.tar.gz
rneovim-d6cac809b009e7066c8761b1466fe08378146d22.tar.bz2
rneovim-d6cac809b009e7066c8761b1466fe08378146d22.zip
tv_dict_watcher_notify: any_needs_free
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/typval.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 726619eb43..fe3d147040 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -1267,6 +1267,7 @@ void tv_dict_watcher_notify(dict_T *const dict, const char *const key,
typval_T rettv;
+ bool any_needs_free = false;
dict->dv_refcount++;
QUEUE *w;
QUEUE_FOREACH(w, &dict->watchers, {
@@ -1277,15 +1278,20 @@ void tv_dict_watcher_notify(dict_T *const dict, const char *const key,
callback_call(&watcher->callback, 3, argv, &rettv);
watcher->busy = false;
tv_clear(&rettv);
+ if (watcher->needs_free) {
+ any_needs_free = true;
+ }
}
})
- QUEUE_FOREACH(w, &dict->watchers, {
- DictWatcher *watcher = tv_dict_watcher_node_data(w);
- if (watcher->needs_free) {
- QUEUE_REMOVE(w);
- tv_dict_watcher_free(watcher);
- }
- })
+ if (any_needs_free) {
+ QUEUE_FOREACH(w, &dict->watchers, {
+ DictWatcher *watcher = tv_dict_watcher_node_data(w);
+ if (watcher->needs_free) {
+ QUEUE_REMOVE(w);
+ tv_dict_watcher_free(watcher);
+ }
+ })
+ }
tv_dict_unref(dict);
for (size_t i = 1; i < ARRAY_SIZE(argv); i++) {