Mercurial > vim
comparison src/ex_cmds.c @ 5776:845608965bd9 v7.4.232
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)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Tue, 01 Apr 2014 17:49:44 +0200 |
parents | 50dbef5e774a |
children | 80421d934ebd |
comparison
equal
deleted
inserted
replaced
5775:af55d5dad6cf | 5776:845608965bd9 |
---|---|
4416 sub = old_sub; | 4416 sub = old_sub; |
4417 | 4417 |
4418 /* Vi compatibility quirk: repeating with ":s" keeps the cursor in the | 4418 /* Vi compatibility quirk: repeating with ":s" keeps the cursor in the |
4419 * last column after using "$". */ | 4419 * last column after using "$". */ |
4420 endcolumn = (curwin->w_curswant == MAXCOL); | 4420 endcolumn = (curwin->w_curswant == MAXCOL); |
4421 } | |
4422 | |
4423 /* Recognize ":%s/\n//" and turn it into a join command, which is much | |
4424 * more efficient. | |
4425 * TODO: find a generic solution to make line-joining operations more | |
4426 * efficient, avoid allocating a string that grows in size. | |
4427 */ | |
4428 if (STRCMP(pat, "\\n") == 0 && STRLEN(pat) == 2 | |
4429 && *sub == NUL | |
4430 && (*cmd == NUL || (cmd[1] == NUL && (*cmd == 'g' || *cmd == 'l' | |
4431 || *cmd == 'p' || *cmd == '#')))) | |
4432 { | |
4433 curwin->w_cursor.lnum = eap->line1; | |
4434 if (*cmd == 'l') | |
4435 eap->flags = EXFLAG_LIST; | |
4436 else if (*cmd == '#') | |
4437 eap->flags = EXFLAG_NR; | |
4438 else if (*cmd == 'p') | |
4439 eap->flags = EXFLAG_PRINT; | |
4440 | |
4441 (void)do_join(eap->line2 - eap->line1 + 1, FALSE, TRUE, FALSE); | |
4442 sub_nlines = sub_nsubs = eap->line2 - eap->line1 + 1; | |
4443 (void)do_sub_msg(FALSE); | |
4444 ex_may_print(eap); | |
4445 return; | |
4421 } | 4446 } |
4422 | 4447 |
4423 /* | 4448 /* |
4424 * Find trailing options. When '&' is used, keep old options. | 4449 * Find trailing options. When '&' is used, keep old options. |
4425 */ | 4450 */ |