073263
To: vim_dev@googlegroups.com
073263
Subject: Patch 7.4.232
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.232
073263
Problem:    ":%s/\n//" uses a lot of memory. (Aidan Marlin)
073263
Solution:   Turn this into a join command. (Christian Brabandt)
073263
Files:	    src/ex_cmds.c, src/ex_docmd.c, src/proto/ex_docmd.pro
073263
073263
073263
*** ../vim-7.4.231/src/ex_cmds.c	2014-03-23 15:12:29.919264336 +0100
073263
--- src/ex_cmds.c	2014-04-01 17:37:59.560901015 +0200
073263
***************
073263
*** 4420,4425 ****
073263
--- 4420,4450 ----
073263
  	endcolumn = (curwin->w_curswant == MAXCOL);
073263
      }
073263
  
073263
+     /* Recognize ":%s/\n//" and turn it into a join command, which is much
073263
+      * more efficient.
073263
+      * TODO: find a generic solution to make line-joining operations more
073263
+      * efficient, avoid allocating a string that grows in size.
073263
+      */
073263
+     if (STRCMP(pat, "\\n") == 0 && STRLEN(pat) == 2
073263
+ 	    && *sub == NUL
073263
+ 	    && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'
073263
+ 					     || *cmd == 'p' || *cmd == '#'))))
073263
+     {
073263
+ 	curwin->w_cursor.lnum = eap->line1;
073263
+ 	if (*cmd == 'l')
073263
+ 	    eap->flags = EXFLAG_LIST;
073263
+ 	else if (*cmd == '#')
073263
+ 	    eap->flags = EXFLAG_NR;
073263
+ 	else if (*cmd == 'p')
073263
+ 	    eap->flags = EXFLAG_PRINT;
073263
+ 
073263
+ 	(void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE);
073263
+ 	sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
073263
+ 	(void)do_sub_msg(FALSE);
073263
+ 	ex_may_print(eap);
073263
+ 	return;
073263
+     }
073263
+ 
073263
      /*
073263
       * Find trailing options.  When '&' is used, keep old options.
073263
       */
073263
*** ../vim-7.4.231/src/ex_docmd.c	2014-03-25 13:03:44.937793766 +0100
073263
--- src/ex_docmd.c	2014-04-01 17:31:59.708905965 +0200
073263
***************
073263
*** 316,322 ****
073263
  static void	ex_operators __ARGS((exarg_T *eap));
073263
  static void	ex_put __ARGS((exarg_T *eap));
073263
  static void	ex_copymove __ARGS((exarg_T *eap));
073263
- static void	ex_may_print __ARGS((exarg_T *eap));
073263
  static void	ex_submagic __ARGS((exarg_T *eap));
073263
  static void	ex_join __ARGS((exarg_T *eap));
073263
  static void	ex_at __ARGS((exarg_T *eap));
073263
--- 316,321 ----
073263
***************
073263
*** 8683,8689 ****
073263
  /*
073263
   * Print the current line if flags were given to the Ex command.
073263
   */
073263
!     static void
073263
  ex_may_print(eap)
073263
      exarg_T	*eap;
073263
  {
073263
--- 8682,8688 ----
073263
  /*
073263
   * Print the current line if flags were given to the Ex command.
073263
   */
073263
!     void
073263
  ex_may_print(eap)
073263
      exarg_T	*eap;
073263
  {
073263
*** ../vim-7.4.231/src/proto/ex_docmd.pro	2013-08-10 13:37:10.000000000 +0200
073263
--- src/proto/ex_docmd.pro	2014-04-01 17:31:59.708905965 +0200
073263
***************
073263
*** 54,57 ****
073263
--- 54,58 ----
073263
  int put_line __ARGS((FILE *fd, char *s));
073263
  void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
073263
  char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
073263
+ void ex_may_print __ARGS((exarg_T *eap));
073263
  /* vim: set ft=c : */
073263
*** ../vim-7.4.231/src/version.c	2014-04-01 14:08:14.689074130 +0200
073263
--- src/version.c	2014-04-01 17:33:03.920905082 +0200
073263
***************
073263
*** 736,737 ****
073263
--- 736,739 ----
073263
  {   /* Add new patch number below this line */
073263
+ /**/
073263
+     232,
073263
  /**/
073263
073263
-- 
073263
hundred-and-one symptoms of being an internet addict:
073263
16. You step out of your room and realize that your parents have moved and
073263
    you don't have a clue when it happened.
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    ///