Patch 8.0.0551
Problem: The typeahead buffer is reallocated too often.
Solution: Re-use the existing buffer if possible.
Files: src/getchar.c
*** ../vim-8.0.0550/src/getchar.c 2017-04-07 19:50:08.687049344 +0200
--- src/getchar.c 2017-04-08 18:33:14.982907218 +0200
***************
*** 920,926 ****
typebuf.tb_noremap = noremapbuf_init;
typebuf.tb_buflen = TYPELEN_INIT;
typebuf.tb_len = 0;
! typebuf.tb_off = 0;
typebuf.tb_change_cnt = 1;
}
}
--- 920,926 ----
typebuf.tb_noremap = noremapbuf_init;
typebuf.tb_buflen = TYPELEN_INIT;
typebuf.tb_len = 0;
! typebuf.tb_off = MAXMAPLEN + 4;
typebuf.tb_change_cnt = 1;
}
}
***************
*** 974,984 ****
typebuf.tb_off -= addlen;
mch_memmove(typebuf.tb_buf + typebuf.tb_off, str, (size_t)addlen);
}
else
{
/*
* Need to allocate a new buffer.
! * In typebuf.tb_buf there must always be room for 3 * MAXMAPLEN + 4
* characters. We add some extra room to avoid having to allocate too
* often.
*/
--- 974,994 ----
typebuf.tb_off -= addlen;
mch_memmove(typebuf.tb_buf + typebuf.tb_off, str, (size_t)addlen);
}
+ else if (typebuf.tb_len == 0 && typebuf.tb_buflen
+ >= addlen + 3 * (MAXMAPLEN + 4))
+ {
+ /*
+ * Buffer is empty and string fits in the existing buffer.
+ * Leave some space before and after, if possible.
+ */
+ typebuf.tb_off = (typebuf.tb_buflen - addlen - 3 * (MAXMAPLEN + 4)) / 2;
+ mch_memmove(typebuf.tb_buf + typebuf.tb_off, str, (size_t)addlen);
+ }
else
{
/*
* Need to allocate a new buffer.
! * In typebuf.tb_buf there must always be room for 3 * (MAXMAPLEN + 4)
* characters. We add some extra room to avoid having to allocate too
* often.
*/
***************
*** 1291,1297 ****
return FAIL;
}
typebuf.tb_buflen = TYPELEN_INIT;
! typebuf.tb_off = 0;
typebuf.tb_len = 0;
typebuf.tb_maplen = 0;
typebuf.tb_silent = 0;
--- 1301,1307 ----
return FAIL;
}
typebuf.tb_buflen = TYPELEN_INIT;
! typebuf.tb_off = MAXMAPLEN + 4; /* can insert without realloc */
typebuf.tb_len = 0;
typebuf.tb_maplen = 0;
typebuf.tb_silent = 0;
*** ../vim-8.0.0550/src/version.c 2017-04-07 20:30:24.196092735 +0200
--- src/version.c 2017-04-08 18:40:08.468310983 +0200
***************
*** 766,767 ****
--- 766,769 ----
{ /* Add new patch number below this line */
+ /**/
+ 551,
/**/
--
Facepalm statement #7: "Last week I almost got pregnant!"
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.