3ef2ca
To: vim_dev@googlegroups.com
3ef2ca
Subject: Patch 7.4.615
3ef2ca
Fcc: outbox
3ef2ca
From: Bram Moolenaar <Bram@moolenaar.net>
3ef2ca
Mime-Version: 1.0
3ef2ca
Content-Type: text/plain; charset=UTF-8
3ef2ca
Content-Transfer-Encoding: 8bit
3ef2ca
------------
3ef2ca
3ef2ca
Patch 7.4.615
3ef2ca
Problem:    Vim hangs when freeing a lot of objects.
3ef2ca
Solution:   Do not go back to the start of the list every time.  (Yasuhiro
3ef2ca
	    Matsumoto and Ariya Mizutani)
3ef2ca
Files:	    src/eval.c
3ef2ca
3ef2ca
3ef2ca
*** ../vim-7.4.614/src/eval.c	2015-02-03 12:55:11.136179596 +0100
3ef2ca
--- src/eval.c	2015-02-03 17:02:59.497727303 +0100
3ef2ca
***************
3ef2ca
*** 5974,5980 ****
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * Free a list, including all items it points to.
3ef2ca
   * Ignores the reference count.
3ef2ca
   */
3ef2ca
      void
3ef2ca
--- 5974,5980 ----
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * Free a list, including all non-container items it points to.
3ef2ca
   * Ignores the reference count.
3ef2ca
   */
3ef2ca
      void
3ef2ca
***************
3ef2ca
*** 6941,6954 ****
3ef2ca
  free_unref_items(copyID)
3ef2ca
      int copyID;
3ef2ca
  {
3ef2ca
!     dict_T	*dd;
3ef2ca
!     list_T	*ll;
3ef2ca
      int		did_free = FALSE;
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * Go through the list of dicts and free items without the copyID.
3ef2ca
       */
3ef2ca
      for (dd = first_dict; dd != NULL; )
3ef2ca
  	if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK))
3ef2ca
  	{
3ef2ca
  	    /* Free the Dictionary and ordinary items it contains, but don't
3ef2ca
--- 6941,6956 ----
3ef2ca
  free_unref_items(copyID)
3ef2ca
      int copyID;
3ef2ca
  {
3ef2ca
!     dict_T	*dd, *dd_next;
3ef2ca
!     list_T	*ll, *ll_next;
3ef2ca
      int		did_free = FALSE;
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * Go through the list of dicts and free items without the copyID.
3ef2ca
       */
3ef2ca
      for (dd = first_dict; dd != NULL; )
3ef2ca
+     {
3ef2ca
+ 	dd_next = dd->dv_used_next;
3ef2ca
  	if ((dd->dv_copyID & COPYID_MASK) != (copyID & COPYID_MASK))
3ef2ca
  	{
3ef2ca
  	    /* Free the Dictionary and ordinary items it contains, but don't
3ef2ca
***************
3ef2ca
*** 6956,6967 ****
3ef2ca
  	     * of dicts or list of lists. */
3ef2ca
  	    dict_free(dd, FALSE);
3ef2ca
  	    did_free = TRUE;
3ef2ca
- 
3ef2ca
- 	    /* restart, next dict may also have been freed */
3ef2ca
- 	    dd = first_dict;
3ef2ca
  	}
3ef2ca
! 	else
3ef2ca
! 	    dd = dd->dv_used_next;
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * Go through the list of lists and free items without the copyID.
3ef2ca
--- 6958,6966 ----
3ef2ca
  	     * of dicts or list of lists. */
3ef2ca
  	    dict_free(dd, FALSE);
3ef2ca
  	    did_free = TRUE;
3ef2ca
  	}
3ef2ca
! 	dd = dd_next;
3ef2ca
!     }
3ef2ca
  
3ef2ca
      /*
3ef2ca
       * Go through the list of lists and free items without the copyID.
3ef2ca
***************
3ef2ca
*** 6969,6974 ****
3ef2ca
--- 6968,6975 ----
3ef2ca
       * are not referenced anywhere.
3ef2ca
       */
3ef2ca
      for (ll = first_list; ll != NULL; )
3ef2ca
+     {
3ef2ca
+ 	ll_next = ll->lv_used_next;
3ef2ca
  	if ((ll->lv_copyID & COPYID_MASK) != (copyID & COPYID_MASK)
3ef2ca
  						      && ll->lv_watch == NULL)
3ef2ca
  	{
3ef2ca
***************
3ef2ca
*** 6977,6989 ****
3ef2ca
  	     * or list of lists. */
3ef2ca
  	    list_free(ll, FALSE);
3ef2ca
  	    did_free = TRUE;
3ef2ca
- 
3ef2ca
- 	    /* restart, next list may also have been freed */
3ef2ca
- 	    ll = first_list;
3ef2ca
  	}
3ef2ca
! 	else
3ef2ca
! 	    ll = ll->lv_used_next;
3ef2ca
! 
3ef2ca
      return did_free;
3ef2ca
  }
3ef2ca
  
3ef2ca
--- 6978,6986 ----
3ef2ca
  	     * or list of lists. */
3ef2ca
  	    list_free(ll, FALSE);
3ef2ca
  	    did_free = TRUE;
3ef2ca
  	}
3ef2ca
! 	ll = ll_next;
3ef2ca
!     }
3ef2ca
      return did_free;
3ef2ca
  }
3ef2ca
  
3ef2ca
***************
3ef2ca
*** 7213,7219 ****
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * Free a Dictionary, including all items it contains.
3ef2ca
   * Ignores the reference count.
3ef2ca
   */
3ef2ca
      void
3ef2ca
--- 7210,7216 ----
3ef2ca
  }
3ef2ca
  
3ef2ca
  /*
3ef2ca
!  * Free a Dictionary, including all non-container items it contains.
3ef2ca
   * Ignores the reference count.
3ef2ca
   */
3ef2ca
      void
3ef2ca
*** ../vim-7.4.614/src/version.c	2015-02-03 16:53:47.155669292 +0100
3ef2ca
--- src/version.c	2015-02-03 16:56:07.790157478 +0100
3ef2ca
***************
3ef2ca
*** 743,744 ****
3ef2ca
--- 743,746 ----
3ef2ca
  {   /* Add new patch number below this line */
3ef2ca
+ /**/
3ef2ca
+     615,
3ef2ca
  /**/
3ef2ca
3ef2ca
-- 
3ef2ca
hundred-and-one symptoms of being an internet addict:
3ef2ca
170. You introduce your wife as "my_lady@home.wife" and refer to your
3ef2ca
     children as "forked processes."
3ef2ca
3ef2ca
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
3ef2ca
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
3ef2ca
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
3ef2ca
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///