summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2014-11-05 16:03:44 +0100
committerBram Moolenaar <Bram@vim.org>2014-11-05 16:03:44 +0100
commite90c853ff6dcef63bff80be0e7379a80c276af8f (patch)
treea4cf516c33cd66d8b819134247854545a2b331c8
parent9c7d98d7c2b81e6e0b4d45389c56fc0e922a5bfe (diff)
updated for version 7.4.499v7.4.499
Problem: substitute() can be slow with long strings. Solution: Store a pointer to the end, instead of calling strlen() every time. (Ozaki Kiichi)
-rw-r--r--src/eval.c4
-rw-r--r--src/version.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/src/eval.c b/src/eval.c
index f5aa7e919e..ecc5e3a572 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -25076,6 +25076,7 @@ do_string_sub(str, pat, sub, flags)
int i;
int do_all;
char_u *tail;
+ char_u *end;
garray_T ga;
char_u *ret;
char_u *save_cpo;
@@ -25094,6 +25095,7 @@ do_string_sub(str, pat, sub, flags)
if (regmatch.regprog != NULL)
{
tail = str;
+ end = str + STRLEN(str);
while (vim_regexec_nl(&regmatch, str, (colnr_T)(tail - str)))
{
/* Skip empty match except for first match. */
@@ -25120,7 +25122,7 @@ do_string_sub(str, pat, sub, flags)
* - The text after the match.
*/
sublen = vim_regsub(&regmatch, sub, tail, FALSE, TRUE, FALSE);
- if (ga_grow(&ga, (int)(STRLEN(tail) + sublen -
+ if (ga_grow(&ga, (int)((end - tail) + sublen -
(regmatch.endp[0] - regmatch.startp[0]))) == FAIL)
{
ga_clear(&ga);
diff --git a/src/version.c b/src/version.c
index ae1a56b5b5..9008518e23 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 499,
+/**/
498,
/**/
497,