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