aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/quickfix.c
diff options
context:
space:
mode:
authorMarco Hinz <mh.codebro@gmail.com>2017-01-09 02:03:03 +0100
committerJames McCoy <jamessan@jamessan.com>2017-02-04 17:55:29 -0500
commite177226d51feb99e159773eebe6a773732fc89e9 (patch)
treedece7dd4cbc637b940393e19d5e117b323594a5c /src/nvim/quickfix.c
parent951dd1571cbb57b41274c0e515e2b3c789305bad (diff)
downloadrneovim-e177226d51feb99e159773eebe6a773732fc89e9.tar.gz
rneovim-e177226d51feb99e159773eebe6a773732fc89e9.tar.bz2
rneovim-e177226d51feb99e159773eebe6a773732fc89e9.zip
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. https://github.com/vim/vim/commit/b25f9a97e9aad3cbb4bc3fe87cdbd5700f8aa0c6
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r--src/nvim/quickfix.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c
index 7b22c95967..4e582108c5 100644
--- a/src/nvim/quickfix.c
+++ b/src/nvim/quickfix.c
@@ -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;