summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2012-02-22 18:12:32 +0100
committerBram Moolenaar <Bram@vim.org>2012-02-22 18:12:32 +0100
commit7282bc3e7e06c77675fd6e7da3d859f26d0f5114 (patch)
tree6c82833ad233a6412f14007adc1b2d2e47f8e611
parent58437e0409e35852c32f8633bdc0a3daa01e001d (diff)
downloadvim-git-7282bc3e7e06c77675fd6e7da3d859f26d0f5114.tar.gz
updated for version 7.3.454v7.3.454
Problem: Re-allocating memory slows Vim down. Solution: Use realloc() in ga_grow(). (Dominique Pelle)
-rw-r--r--src/misc2.c16
-rw-r--r--src/version.c2
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
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 454,
+/**/
453,
/**/
452,