]> granicus.if.org Git - vim/commitdiff
updated for version 7.4.232 v7.4.232
authorBram Moolenaar <Bram@vim.org>
Tue, 1 Apr 2014 15:49:44 +0000 (17:49 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 1 Apr 2014 15:49:44 +0000 (17:49 +0200)
Problem:    ":%s/\n//" uses a lot of memory. (Aidan Marlin)
Solution:   Turn this into a join command. (Christian Brabandt)

src/ex_cmds.c
src/ex_docmd.c
src/proto/ex_docmd.pro
src/version.c

index f99f8830fb6c783ea4e51ff02443a704e419b52c..5321955cf5aee69f375df071b14706ea5cb54bbd 100644 (file)
@@ -4420,6 +4420,31 @@ do_sub(eap)
        endcolumn = (curwin->w_curswant == MAXCOL);
     }
 
+    /* Recognize ":%s/\n//" and turn it into a join command, which is much
+     * more efficient.
+     * TODO: find a generic solution to make line-joining operations more
+     * efficient, avoid allocating a string that grows in size.
+     */
+    if (STRCMP(pat, "\\n") == 0 && STRLEN(pat) == 2
+           && *sub == NUL
+           && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l'
+                                            || *cmd == 'p' || *cmd == '#'))))
+    {
+       curwin->w_cursor.lnum = eap->line1;
+       if (*cmd == 'l')
+           eap->flags = EXFLAG_LIST;
+       else if (*cmd == '#')
+           eap->flags = EXFLAG_NR;
+       else if (*cmd == 'p')
+           eap->flags = EXFLAG_PRINT;
+
+       (void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE);
+       sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
+       (void)do_sub_msg(FALSE);
+       ex_may_print(eap);
+       return;
+    }
+
     /*
      * Find trailing options.  When '&' is used, keep old options.
      */
index a63f8f66b24140ab14b17fb82b5dfd96c15f89b3..f1aa60798d1de011ab0cb5c8602149f74e88ac24 100644 (file)
@@ -316,7 +316,6 @@ static void ex_winpos __ARGS((exarg_T *eap));
 static void    ex_operators __ARGS((exarg_T *eap));
 static void    ex_put __ARGS((exarg_T *eap));
 static void    ex_copymove __ARGS((exarg_T *eap));
-static void    ex_may_print __ARGS((exarg_T *eap));
 static void    ex_submagic __ARGS((exarg_T *eap));
 static void    ex_join __ARGS((exarg_T *eap));
 static void    ex_at __ARGS((exarg_T *eap));
@@ -8683,7 +8682,7 @@ ex_copymove(eap)
 /*
  * Print the current line if flags were given to the Ex command.
  */
-    static void
+    void
 ex_may_print(eap)
     exarg_T    *eap;
 {
index 816fd3fd5411d7b1c5e3cf93e3f2fb11ab0f3906..ebc54c9deb3af6a5b67a6bba0ab77b15c0f5d2b4 100644 (file)
@@ -54,4 +54,5 @@ int put_eol __ARGS((FILE *fd));
 int put_line __ARGS((FILE *fd, char *s));
 void dialog_msg __ARGS((char_u *buff, char *format, char_u *fname));
 char_u *get_behave_arg __ARGS((expand_T *xp, int idx));
+void ex_may_print __ARGS((exarg_T *eap));
 /* vim: set ft=c : */
index bd6ad3f43280c658777c504af15feb44d35aa1ef..1780946fc5d37d88fb63138c6b713451286f241f 100644 (file)
@@ -734,6 +734,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    232,
 /**/
     231,
 /**/