mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.232
Problem: ":%s/\n//" uses a lot of memory. (Aidan Marlin) Solution: Turn this into a join command. (Christian Brabandt) https://code.google.com/p/vim/source/detail?r=845608965bd9d0b2755997a7be812746885ff105
This commit is contained in:
parent
d322be894e
commit
0e1e9148a3
@ -3653,6 +3653,35 @@ void do_sub(exarg_T *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((const char *)pat, "\\n") == 0
|
||||
&& strlen((const char *)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;
|
||||
}
|
||||
|
||||
do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE);
|
||||
sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1;
|
||||
do_sub_msg(FALSE);
|
||||
ex_may_print(eap);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find trailing options. When '&' is used, keep old options.
|
||||
*/
|
||||
|
@ -182,7 +182,6 @@ static void ex_winpos(exarg_T *eap);
|
||||
static void ex_operators(exarg_T *eap);
|
||||
static void ex_put(exarg_T *eap);
|
||||
static void ex_copymove(exarg_T *eap);
|
||||
static void ex_may_print(exarg_T *eap);
|
||||
static void ex_submagic(exarg_T *eap);
|
||||
static void ex_join(exarg_T *eap);
|
||||
static void ex_at(exarg_T *eap);
|
||||
@ -6906,7 +6905,7 @@ static void ex_copymove(exarg_T *eap)
|
||||
/*
|
||||
* Print the current line if flags were given to the Ex command.
|
||||
*/
|
||||
static void ex_may_print(exarg_T *eap)
|
||||
void ex_may_print(exarg_T *eap)
|
||||
{
|
||||
if (eap->flags != 0) {
|
||||
print_line(curwin->w_cursor.lnum, (eap->flags & EXFLAG_NR),
|
||||
|
@ -23,6 +23,7 @@ char_u *find_nextcmd(char_u *p);
|
||||
char_u *check_nextcmd(char_u *p);
|
||||
char_u *get_command_name(expand_T *xp, int idx);
|
||||
void ex_comclear(exarg_T *eap);
|
||||
void ex_may_print(exarg_T *eap);
|
||||
void uc_clear(garray_T *gap);
|
||||
char_u *get_user_commands(expand_T *xp, int idx);
|
||||
char_u *get_user_cmd_flags(expand_T *xp, int idx);
|
||||
|
@ -229,7 +229,7 @@ static int included_patches[] = {
|
||||
//235,
|
||||
//234,
|
||||
//233,
|
||||
//232,
|
||||
232,
|
||||
//231,
|
||||
//230,
|
||||
229,
|
||||
|
Loading…
Reference in New Issue
Block a user