diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-24 15:31:43 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-02-24 15:36:08 +0800 |
commit | ec2557236710f3e062164e7ff4b137b2a0d8dfa4 (patch) | |
tree | 17296bbaf119f38e779951c0e5f68f575e3c0caa | |
parent | d9263688bf0282918f5a9801dae8b85e4c85bd7e (diff) | |
download | rneovim-ec2557236710f3e062164e7ff4b137b2a0d8dfa4.tar.gz rneovim-ec2557236710f3e062164e7ff4b137b2a0d8dfa4.tar.bz2 rneovim-ec2557236710f3e062164e7ff4b137b2a0d8dfa4.zip |
vim-patch:8.2.4629: flattennew() makes a deep copy unnecessarily
Problem: flattennew() makes a deep copy unnecessarily.
Solution: Use a shallow copy. (issue vim/vim#10012)
https://github.com/vim/vim/commit/c6c1ec4da53db9d292fa3dd081c20123f8261178
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/eval/funcs.c | 2 | ||||
-rw-r--r-- | src/nvim/eval/typval.c | 4 |
2 files changed, 2 insertions, 4 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 6ac94706c7..f1852f1b6d 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -1902,7 +1902,7 @@ static void flatten_common(typval_T *argvars, typval_T *rettv, bool make_copy) } if (make_copy) { - list = tv_list_copy(NULL, list, true, get_copyID()); + list = tv_list_copy(NULL, list, false, get_copyID()); rettv->vval.v_list = list; if (list == NULL) { return; diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index 125a4310d8..9faf19c364 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -659,7 +659,6 @@ void tv_list_flatten(list_T *list, listitem_T *first, long maxitems, long maxdep FUNC_ATTR_NONNULL_ARG(1) { listitem_T *item; - listitem_T *to_free; int done = 0; if (maxdepth == 0) { return; @@ -684,14 +683,13 @@ void tv_list_flatten(list_T *list, listitem_T *first, long maxitems, long maxdep tv_list_drop_items(list, item, item); tv_list_extend(list, itemlist, next); tv_clear(&item->li_tv); - to_free = item; if (maxdepth > 0) { tv_list_flatten(list, item->li_prev == NULL ? list->lv_first : item->li_prev->li_next, itemlist->lv_len, maxdepth - 1); } - xfree(to_free); + xfree(item); } done++; |