summaryrefslogtreecommitdiff
path: root/src/list.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-03-26 10:50:11 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-26 10:50:11 +0000
commitc6c1ec4da53db9d292fa3dd081c20123f8261178 (patch)
tree3f6ed5205c02f8b48adf98567202bfc6792b511b /src/list.c
parent5e877baf87530d5c4fe4da2c5a6269cf19526c27 (diff)
downloadvim-git-c6c1ec4da53db9d292fa3dd081c20123f8261178.tar.gz
patch 8.2.4629: flattennew() makes a deep copy unnecessarilyv8.2.4629
Problem: flattennew() makes a deep copy unnecessarily. Solution: Use a shallow copy. (issue #10012)
Diffstat (limited to 'src/list.c')
-rw-r--r--src/list.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/list.c b/src/list.c
index 930904817..3354068a4 100644
--- a/src/list.c
+++ b/src/list.c
@@ -925,7 +925,6 @@ list_assign_range(
list_flatten(list_T *list, listitem_T *first, long maxitems, long maxdepth)
{
listitem_T *item;
- listitem_T *tofree;
int done = 0;
if (maxdepth == 0)
@@ -955,13 +954,12 @@ list_flatten(list_T *list, listitem_T *first, long maxitems, long maxdepth)
return;
}
clear_tv(&item->li_tv);
- tofree = item;
if (maxdepth > 0)
list_flatten(list, item->li_prev == NULL
? list->lv_first : item->li_prev->li_next,
itemlist->lv_len, maxdepth - 1);
- list_free_item(list, tofree);
+ list_free_item(list, item);
}
++done;
@@ -1012,7 +1010,7 @@ flatten_common(typval_T *argvars, typval_T *rettv, int make_copy)
if (make_copy)
{
- l = list_copy(l, TRUE, TRUE, get_copyID());
+ l = list_copy(l, FALSE, TRUE, get_copyID());
rettv->vval.v_list = l;
if (l == NULL)
return;