]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.454 v7.3.454
authorBram Moolenaar <Bram@vim.org>
Wed, 22 Feb 2012 17:12:32 +0000 (18:12 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 22 Feb 2012 17:12:32 +0000 (18:12 +0100)
Problem:    Re-allocating memory slows Vim down.
Solution:   Use realloc() in ga_grow(). (Dominique Pelle)

src/misc2.c
src/version.c

index a070a20a5dd46c3cba579f6cd009b54b4e31effb..81838765058024f2b81954f26103f17234049b0d 100644 (file)
@@ -2064,24 +2064,22 @@ ga_grow(gap, n)
     garray_T   *gap;
     int                n;
 {
-    size_t     len;
+    size_t     old_len;
+    size_t     new_len;
     char_u     *pp;
 
     if (gap->ga_maxlen - gap->ga_len < n)
     {
        if (n < gap->ga_growsize)
            n = gap->ga_growsize;
-       len = gap->ga_itemsize * (gap->ga_len + n);
-       pp = alloc_clear((unsigned)len);
+       new_len = gap->ga_itemsize * (gap->ga_len + n);
+       pp = (gap->ga_data == NULL)
+                       ? alloc(new_len) : vim_realloc(gap->ga_data, new_len);
        if (pp == NULL)
            return FAIL;
+       old_len = gap->ga_itemsize * gap->ga_maxlen;
+       vim_memset(pp + old_len, 0, new_len - old_len);
        gap->ga_maxlen = gap->ga_len + n;
-       if (gap->ga_data != NULL)
-       {
-           mch_memmove(pp, gap->ga_data,
-                                     (size_t)(gap->ga_itemsize * gap->ga_len));
-           vim_free(gap->ga_data);
-       }
        gap->ga_data = pp;
     }
     return OK;
index c3d3555ab391c1f41e05bcfffe080ef76b14f0f2..169b9efe6c2c8c7b42a8c28365e57f121551d367 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    454,
 /**/
     453,
 /**/