From 7282bc3e7e06c77675fd6e7da3d859f26d0f5114 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 22 Feb 2012 18:12:32 +0100 Subject: [PATCH] updated for version 7.3.454 Problem: Re-allocating memory slows Vim down. Solution: Use realloc() in ga_grow(). (Dominique Pelle) --- src/misc2.c | 16 +++++++--------- src/version.c | 2 ++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/misc2.c b/src/misc2.c index a070a20a5..818387650 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -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; diff --git a/src/version.c b/src/version.c index c3d3555ab..169b9efe6 100644 --- a/src/version.c +++ b/src/version.c @@ -714,6 +714,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 454, /**/ 453, /**/ -- 2.40.0