Karsten Hopp cc8e67
To: vim_dev@googlegroups.com
Karsten Hopp cc8e67
Subject: Patch 7.3.454
Karsten Hopp cc8e67
Fcc: outbox
Karsten Hopp cc8e67
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp cc8e67
Mime-Version: 1.0
Karsten Hopp cc8e67
Content-Type: text/plain; charset=UTF-8
Karsten Hopp cc8e67
Content-Transfer-Encoding: 8bit
Karsten Hopp cc8e67
------------
Karsten Hopp cc8e67
Karsten Hopp cc8e67
Patch 7.3.454
Karsten Hopp cc8e67
Problem:    Re-allocating memory slows Vim down.
Karsten Hopp cc8e67
Solution:   Use realloc() in ga_grow(). (Dominique Pelle)
Karsten Hopp cc8e67
Files:	    src/misc2.c
Karsten Hopp cc8e67
Karsten Hopp cc8e67
Karsten Hopp cc8e67
*** ../vim-7.3.453/src/misc2.c	2012-02-22 14:58:24.000000000 +0100
Karsten Hopp cc8e67
--- src/misc2.c	2012-02-22 18:07:45.000000000 +0100
Karsten Hopp cc8e67
***************
Karsten Hopp cc8e67
*** 2064,2087 ****
Karsten Hopp cc8e67
      garray_T	*gap;
Karsten Hopp cc8e67
      int		n;
Karsten Hopp cc8e67
  {
Karsten Hopp cc8e67
!     size_t	len;
Karsten Hopp cc8e67
      char_u	*pp;
Karsten Hopp cc8e67
  
Karsten Hopp cc8e67
      if (gap->ga_maxlen - gap->ga_len < n)
Karsten Hopp cc8e67
      {
Karsten Hopp cc8e67
  	if (n < gap->ga_growsize)
Karsten Hopp cc8e67
  	    n = gap->ga_growsize;
Karsten Hopp cc8e67
! 	len = gap->ga_itemsize * (gap->ga_len + n);
Karsten Hopp cc8e67
! 	pp = alloc_clear((unsigned)len);
Karsten Hopp cc8e67
  	if (pp == NULL)
Karsten Hopp cc8e67
  	    return FAIL;
Karsten Hopp cc8e67
  	gap->ga_maxlen = gap->ga_len + n;
Karsten Hopp cc8e67
- 	if (gap->ga_data != NULL)
Karsten Hopp cc8e67
- 	{
Karsten Hopp cc8e67
- 	    mch_memmove(pp, gap->ga_data,
Karsten Hopp cc8e67
- 				      (size_t)(gap->ga_itemsize * gap->ga_len));
Karsten Hopp cc8e67
- 	    vim_free(gap->ga_data);
Karsten Hopp cc8e67
- 	}
Karsten Hopp cc8e67
  	gap->ga_data = pp;
Karsten Hopp cc8e67
      }
Karsten Hopp cc8e67
      return OK;
Karsten Hopp cc8e67
--- 2064,2085 ----
Karsten Hopp cc8e67
      garray_T	*gap;
Karsten Hopp cc8e67
      int		n;
Karsten Hopp cc8e67
  {
Karsten Hopp cc8e67
!     size_t	old_len;
Karsten Hopp cc8e67
!     size_t	new_len;
Karsten Hopp cc8e67
      char_u	*pp;
Karsten Hopp cc8e67
  
Karsten Hopp cc8e67
      if (gap->ga_maxlen - gap->ga_len < n)
Karsten Hopp cc8e67
      {
Karsten Hopp cc8e67
  	if (n < gap->ga_growsize)
Karsten Hopp cc8e67
  	    n = gap->ga_growsize;
Karsten Hopp cc8e67
! 	new_len = gap->ga_itemsize * (gap->ga_len + n);
Karsten Hopp cc8e67
! 	pp = (gap->ga_data == NULL)
Karsten Hopp cc8e67
! 			? alloc(new_len) : vim_realloc(gap->ga_data, new_len);
Karsten Hopp cc8e67
  	if (pp == NULL)
Karsten Hopp cc8e67
  	    return FAIL;
Karsten Hopp cc8e67
+ 	old_len = gap->ga_itemsize * gap->ga_maxlen;
Karsten Hopp cc8e67
+ 	vim_memset(pp + old_len, 0, new_len - old_len);
Karsten Hopp cc8e67
  	gap->ga_maxlen = gap->ga_len + n;
Karsten Hopp cc8e67
  	gap->ga_data = pp;
Karsten Hopp cc8e67
      }
Karsten Hopp cc8e67
      return OK;
Karsten Hopp cc8e67
*** ../vim-7.3.453/src/version.c	2012-02-22 17:58:00.000000000 +0100
Karsten Hopp cc8e67
--- src/version.c	2012-02-22 18:09:42.000000000 +0100
Karsten Hopp cc8e67
***************
Karsten Hopp cc8e67
*** 716,717 ****
Karsten Hopp cc8e67
--- 716,719 ----
Karsten Hopp cc8e67
  {   /* Add new patch number below this line */
Karsten Hopp cc8e67
+ /**/
Karsten Hopp cc8e67
+     454,
Karsten Hopp cc8e67
  /**/
Karsten Hopp cc8e67
Karsten Hopp cc8e67
-- 
Karsten Hopp cc8e67
From "know your smileys":
Karsten Hopp cc8e67
 (X0||)   Double hamburger with lettuce and tomato
Karsten Hopp cc8e67
Karsten Hopp cc8e67
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp cc8e67
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp cc8e67
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp cc8e67
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///