mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:7.4.499
Problem: substitute() can be slow with long strings. Solution: Store a pointer to the end, instead of calling strlen() every time. (Ozaki Kiichi) https://code.google.com/p/vim/source/detail?r=v7-4-499
This commit is contained in:
parent
4f6bb8a9a9
commit
2ba50a7846
@ -19665,6 +19665,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
|
|||||||
regmatch_T regmatch;
|
regmatch_T regmatch;
|
||||||
int do_all;
|
int do_all;
|
||||||
char_u *tail;
|
char_u *tail;
|
||||||
|
char_u *end;
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
char_u *save_cpo;
|
char_u *save_cpo;
|
||||||
char_u *zero_width = NULL;
|
char_u *zero_width = NULL;
|
||||||
@ -19681,6 +19682,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
|
|||||||
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
regmatch.regprog = vim_regcomp(pat, RE_MAGIC + RE_STRING);
|
||||||
if (regmatch.regprog != NULL) {
|
if (regmatch.regprog != NULL) {
|
||||||
tail = str;
|
tail = str;
|
||||||
|
end = str + STRLEN(str);
|
||||||
while (vim_regexec_nl(®match, str, (colnr_T)(tail - str))) {
|
while (vim_regexec_nl(®match, str, (colnr_T)(tail - str))) {
|
||||||
/* Skip empty match except for first match. */
|
/* Skip empty match except for first match. */
|
||||||
if (regmatch.startp[0] == regmatch.endp[0]) {
|
if (regmatch.startp[0] == regmatch.endp[0]) {
|
||||||
@ -19703,7 +19705,7 @@ char_u *do_string_sub(char_u *str, char_u *pat, char_u *sub, char_u *flags)
|
|||||||
* - The text after the match.
|
* - The text after the match.
|
||||||
*/
|
*/
|
||||||
sublen = vim_regsub(®match, sub, tail, FALSE, TRUE, FALSE);
|
sublen = vim_regsub(®match, sub, tail, FALSE, TRUE, FALSE);
|
||||||
ga_grow(&ga, (int)(STRLEN(tail) + sublen -
|
ga_grow(&ga, (int)((end - tail) + sublen -
|
||||||
(regmatch.endp[0] - regmatch.startp[0])));
|
(regmatch.endp[0] - regmatch.startp[0])));
|
||||||
|
|
||||||
/* copy the text up to where the match is */
|
/* copy the text up to where the match is */
|
||||||
|
@ -239,7 +239,7 @@ static int included_patches[] = {
|
|||||||
//502,
|
//502,
|
||||||
//501 NA
|
//501 NA
|
||||||
//500,
|
//500,
|
||||||
//499,
|
499,
|
||||||
//498 NA
|
//498 NA
|
||||||
//497,
|
//497,
|
||||||
//496 NA
|
//496 NA
|
||||||
|
Loading…
Reference in New Issue
Block a user