To: vim_dev@googlegroups.com Subject: Patch 8.2.4629 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4629 Problem: flattennew() makes a deep copy unnecessarily. Solution: Use a shallow copy. (issue #10012) Files: src/list.c *** ../vim-8.2.4628/src/list.c 2022-03-25 19:50:53.877135393 +0000 --- src/list.c 2022-03-26 10:29:13.375688883 +0000 *************** *** 925,931 **** list_flatten(list_T *list, listitem_T *first, long maxitems, long maxdepth) { listitem_T *item; - listitem_T *tofree; int done = 0; if (maxdepth == 0) --- 925,930 ---- *************** *** 955,967 **** 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); } ++done; --- 954,965 ---- return; } clear_tv(&item->li_tv); 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, item); } ++done; *************** *** 1012,1018 **** if (make_copy) { ! l = list_copy(l, TRUE, TRUE, get_copyID()); rettv->vval.v_list = l; if (l == NULL) return; --- 1010,1016 ---- if (make_copy) { ! l = list_copy(l, FALSE, TRUE, get_copyID()); rettv->vval.v_list = l; if (l == NULL) return; *** ../vim-8.2.4628/src/version.c 2022-03-25 21:19:22.115496681 +0000 --- src/version.c 2022-03-26 10:48:58.762554937 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4629, /**/ -- Individualists unite! /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///