0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 7.4.2017

Problem:    When there are many errors adding them to the quickfix list takes
            a long time.
Solution:   Add BLN_NOOPT.  Don't call buf_valid() in buf_copy_options().
            Remember the last file name used.  When going through the buffer
            list start from the end of the list.  Only call buf_valid() when
            autocommands were executed.
This commit is contained in:
Bram Moolenaar
2016-07-10 17:00:38 +02:00
parent 2bc127f940
commit 8240433f48
5 changed files with 66 additions and 35 deletions

View File

@@ -1482,6 +1482,13 @@ copy_loclist(win_T *from, win_T *to)
to->w_llist->qf_curlist = qi->qf_curlist; /* current list */
}
/*
* Looking up a buffer can be slow if there are many. Remember the last one
* to make this a lot faster if there are multiple matches in the same file.
*/
static char_u *qf_last_bufname = NULL;
static buf_T *qf_last_buf = NULL;
/*
* Get buffer number for file "dir.name".
* Also sets the b_has_qf_entry flag.
@@ -1489,8 +1496,9 @@ copy_loclist(win_T *from, win_T *to)
static int
qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
{
char_u *ptr;
char_u *ptr = NULL;
buf_T *buf;
char_u *bufname;
if (fname == NULL || *fname == NUL) /* no file name */
return 0;
@@ -1522,13 +1530,30 @@ qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
ptr = vim_strsave(fname);
}
/* Use concatenated directory name and file name */
buf = buflist_new(ptr, NULL, (linenr_T)0, 0);
bufname = ptr;
}
else
bufname = fname;
if (qf_last_bufname != NULL && STRCMP(bufname, qf_last_bufname) == 0
&& buf_valid(qf_last_buf))
{
buf = qf_last_buf;
vim_free(ptr);
}
else
buf = buflist_new(fname, NULL, (linenr_T)0, 0);
{
vim_free(qf_last_bufname);
buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT);
if (bufname == ptr)
qf_last_bufname = bufname;
else
qf_last_bufname = vim_strsave(bufname);
qf_last_buf = buf;
}
if (buf == NULL)
return 0;
buf->b_has_qf_entry = TRUE;
return buf->b_fnum;
}