To: vim_dev@googlegroups.com Subject: Patch 8.2.3089 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3089 Problem: Garbage collection has useless code. Solution: Bail out when aborting. (closes #8504) Files: src/userfunc.c *** ../vim-8.2.3088/src/userfunc.c 2021-06-27 22:03:28.649707714 +0200 --- src/userfunc.c 2021-07-03 16:32:44.105980894 +0200 *************** *** 5478,5512 **** int set_ref_in_previous_funccal(int copyID) { - int abort = FALSE; funccall_T *fc; ! for (fc = previous_funccal; !abort && fc != NULL; fc = fc->caller) { fc->fc_copyID = copyID + 1; ! abort = abort ! || set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID + 1, NULL) ! || set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID + 1, NULL) ! || set_ref_in_list_items(&fc->l_varlist, copyID + 1, NULL); } ! return abort; } static int set_ref_in_funccal(funccall_T *fc, int copyID) { - int abort = FALSE; - if (fc->fc_copyID != copyID) { fc->fc_copyID = copyID; ! abort = abort ! || set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID, NULL) ! || set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID, NULL) ! || set_ref_in_list_items(&fc->l_varlist, copyID, NULL) ! || set_ref_in_func(NULL, fc->func, copyID); } ! return abort; } /* --- 5478,5509 ---- int set_ref_in_previous_funccal(int copyID) { funccall_T *fc; ! for (fc = previous_funccal; fc != NULL; fc = fc->caller) { fc->fc_copyID = copyID + 1; ! if (set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID + 1, NULL) ! || set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID + 1, NULL) ! || set_ref_in_list_items(&fc->l_varlist, copyID + 1, NULL)) ! return TRUE; } ! return FALSE; } static int set_ref_in_funccal(funccall_T *fc, int copyID) { if (fc->fc_copyID != copyID) { fc->fc_copyID = copyID; ! if (set_ref_in_ht(&fc->l_vars.dv_hashtab, copyID, NULL) ! || set_ref_in_ht(&fc->l_avars.dv_hashtab, copyID, NULL) ! || set_ref_in_list_items(&fc->l_varlist, copyID, NULL) ! || set_ref_in_func(NULL, fc->func, copyID)) ! return TRUE; } ! return FALSE; } /* *************** *** 5515,5533 **** int set_ref_in_call_stack(int copyID) { - int abort = FALSE; funccall_T *fc; funccal_entry_T *entry; ! for (fc = current_funccal; !abort && fc != NULL; fc = fc->caller) ! abort = abort || set_ref_in_funccal(fc, copyID); // Also go through the funccal_stack. ! for (entry = funccal_stack; !abort && entry != NULL; entry = entry->next) ! for (fc = entry->top_funccal; !abort && fc != NULL; fc = fc->caller) ! abort = abort || set_ref_in_funccal(fc, copyID); ! ! return abort; } /* --- 5512,5530 ---- int set_ref_in_call_stack(int copyID) { funccall_T *fc; funccal_entry_T *entry; ! for (fc = current_funccal; fc != NULL; fc = fc->caller) ! if (set_ref_in_funccal(fc, copyID)) ! return TRUE; // Also go through the funccal_stack. ! for (entry = funccal_stack; entry != NULL; entry = entry->next) ! for (fc = entry->top_funccal; fc != NULL; fc = fc->caller) ! if (set_ref_in_funccal(fc, copyID)) ! return TRUE; ! return FALSE; } /* *************** *** 5538,5544 **** { int todo; hashitem_T *hi = NULL; - int abort = FALSE; ufunc_T *fp; todo = (int)func_hashtab.ht_used; --- 5535,5540 ---- *************** *** 5548,5558 **** { --todo; fp = HI2UF(hi); ! if (!func_name_refcount(fp->uf_name)) ! abort = abort || set_ref_in_func(NULL, fp, copyID); } } ! return abort; } /* --- 5544,5555 ---- { --todo; fp = HI2UF(hi); ! if (!func_name_refcount(fp->uf_name) ! && set_ref_in_func(NULL, fp, copyID)) ! return TRUE; } } ! return FALSE; } /* *************** *** 5562,5573 **** set_ref_in_func_args(int copyID) { int i; - int abort = FALSE; for (i = 0; i < funcargs.ga_len; ++i) ! abort = abort || set_ref_in_item(((typval_T **)funcargs.ga_data)[i], ! copyID, NULL, NULL); ! return abort; } /* --- 5559,5570 ---- set_ref_in_func_args(int copyID) { int i; for (i = 0; i < funcargs.ga_len; ++i) ! if (set_ref_in_item(((typval_T **)funcargs.ga_data)[i], ! copyID, NULL, NULL)) ! return TRUE; ! return FALSE; } /* *** ../vim-8.2.3088/src/version.c 2021-07-03 15:08:19.341195138 +0200 --- src/version.c 2021-07-03 16:22:28.811426634 +0200 *************** *** 757,758 **** --- 757,760 ---- { /* Add new patch number below this line */ + /**/ + 3089, /**/ -- hundred-and-one symptoms of being an internet addict: 83. Batteries in the TV remote now last for months. /// 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 ///