073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.499
073263
Fcc: outbox
073263
From: Bram Moolenaar <Bram@moolenaar.net>
073263
Mime-Version: 1.0
073263
Content-Type: text/plain; charset=UTF-8
073263
Content-Transfer-Encoding: 8bit
073263
------------
073263
073263
Patch 7.4.499
073263
Problem:    substitute() can be slow with long strings.
073263
Solution:   Store a pointer to the end, instead of calling strlen() every
073263
	    time. (Ozaki Kiichi)
073263
Files:	    src/eval.c
073263
073263
073263
*** ../vim-7.4.498/src/eval.c	2014-10-31 15:45:49.171053328 +0100
073263
--- src/eval.c	2014-11-05 15:49:49.040637923 +0100
073263
***************
073263
*** 25076,25081 ****
073263
--- 25076,25082 ----
073263
      int		i;
073263
      int		do_all;
073263
      char_u	*tail;
073263
+     char_u	*end;
073263
      garray_T	ga;
073263
      char_u	*ret;
073263
      char_u	*save_cpo;
073263
***************
073263
*** 25094,25099 ****
073263
--- 25095,25101 ----
073263
      if (regmatch.regprog != NULL)
073263
      {
073263
  	tail = str;
073263
+ 	end = str + STRLEN(str);
073263
  	while (vim_regexec_nl(&regmatch, str, (colnr_T)(tail - str)))
073263
  	{
073263
  	    /* Skip empty match except for first match. */
073263
***************
073263
*** 25120,25126 ****
073263
  	     * - The text after the match.
073263
  	     */
073263
  	    sublen = vim_regsub(&regmatch, sub, tail, FALSE, TRUE, FALSE);
073263
! 	    if (ga_grow(&ga, (int)(STRLEN(tail) + sublen -
073263
  			    (regmatch.endp[0] - regmatch.startp[0]))) == FAIL)
073263
  	    {
073263
  		ga_clear(&ga);
073263
--- 25122,25128 ----
073263
  	     * - The text after the match.
073263
  	     */
073263
  	    sublen = vim_regsub(&regmatch, sub, tail, FALSE, TRUE, FALSE);
073263
! 	    if (ga_grow(&ga, (int)((end - tail) + sublen -
073263
  			    (regmatch.endp[0] - regmatch.startp[0]))) == FAIL)
073263
  	    {
073263
  		ga_clear(&ga);
073263
*** ../vim-7.4.498/src/version.c	2014-11-05 15:46:06.212643292 +0100
073263
--- src/version.c	2014-11-05 15:50:52.880636385 +0100
073263
***************
073263
*** 743,744 ****
073263
--- 743,746 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     499,
073263
  /**/
073263
073263
-- 
073263
ARTHUR:        A scratch?  Your arm's off!
073263
BLACK KNIGHT:  No, it isn't.
073263
ARTHUR:        Well, what's that then?
073263
BLACK KNIGHT:  I've had worse.
073263
                                  The Quest for the Holy Grail (Monty Python)
073263
073263
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
073263
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
073263
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
073263
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///