mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
updated for version 7.4.232
Problem: ":%s/\n//" uses a lot of memory. (Aidan Marlin) Solution: Turn this into a join command. (Christian Brabandt)
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user