changeset 28207:0090c27f26d3 v8.2.4629

patch 8.2.4629: flattennew() makes a deep copy unnecessarily Commit: https://github.com/vim/vim/commit/c6c1ec4da53db9d292fa3dd081c20123f8261178 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Mar 26 10:50:11 2022 +0000 patch 8.2.4629: flattennew() makes a deep copy unnecessarily Problem: flattennew() makes a deep copy unnecessarily. Solution: Use a shallow copy. (issue https://github.com/vim/vim/issues/10012)
author Bram Moolenaar <Bram@vim.org>
date Sat, 26 Mar 2022 12:00:04 +0100
parents 4d87d761e0eb
children 92e7aeb97a55
files src/list.c src/version.c
diffstat 2 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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 *f
 		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
 
     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;
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    4629,
+/**/
     4628,
 /**/
     4627,