mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 23:38:17 +00:00
vim-patch:7.4.2018
Problem: buf_valid() can be slow when there are many buffers.
Solution: Add bufref_valid(), only go through the buffer list
when a buffer was freed.
b25f9a97e9
This commit is contained in:
@@ -1286,7 +1286,7 @@ void copy_loclist(win_T *from, win_T *to)
|
||||
// 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;
|
||||
static bufref_T qf_last_bufref = { NULL, 0 };
|
||||
|
||||
// Get buffer number for file "directory.fname".
|
||||
// Also sets the b_has_qf_entry flag.
|
||||
@@ -1328,14 +1328,14 @@ static int qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname)
|
||||
|
||||
if (qf_last_bufname != NULL
|
||||
&& STRCMP(bufname, qf_last_bufname) == 0
|
||||
&& buf_valid(qf_last_buf)) {
|
||||
buf = qf_last_buf;
|
||||
&& bufref_valid(&qf_last_bufref)) {
|
||||
buf = qf_last_bufref.br_buf;
|
||||
xfree(ptr);
|
||||
} else {
|
||||
xfree(qf_last_bufname);
|
||||
buf = buflist_new(bufname, NULL, (linenr_T)0, BLN_NOOPT);
|
||||
qf_last_bufname = (bufname == ptr) ? bufname : vim_strsave(bufname);
|
||||
qf_last_buf = buf;
|
||||
set_bufref(&qf_last_bufref, buf);
|
||||
}
|
||||
if (buf == NULL) {
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user