Skip to content

Commit

Permalink
patch 8.2.4629: flattennew() makes a deep copy unnecessarily
Browse files Browse the repository at this point in the history
Problem:    flattennew() makes a deep copy unnecessarily.
Solution:   Use a shallow copy. (issue #10012)
  • Loading branch information
brammool committed Mar 26, 2022
1 parent 5e877ba commit c6c1ec4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
4629,
/**/
4628,
/**/
Expand Down

0 comments on commit c6c1ec4

Please sign in to comment.