diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2017-01-08 16:53:08 +0100 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-02-04 17:15:11 -0500 |
commit | 951dd1571cbb57b41274c0e515e2b3c789305bad (patch) | |
tree | 43b8e5c21de645ee094bc71d3cbe8644368d6cd2 /src/nvim/quickfix.c | |
parent | 6d4e08d226971220b02fd74032f931779a0acd38 (diff) | |
download | rneovim-951dd1571cbb57b41274c0e515e2b3c789305bad.tar.gz rneovim-951dd1571cbb57b41274c0e515e2b3c789305bad.tar.bz2 rneovim-951dd1571cbb57b41274c0e515e2b3c789305bad.zip |
vim-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.
https://github.com/vim/vim/commit/8240433f48f7383c281ba2453cc55f10b8ec47d9
Diffstat (limited to 'src/nvim/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index cebff5e8b7..7b22c95967 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -1283,11 +1283,17 @@ void 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 "directory.fname". // Also sets the b_has_qf_entry flag. static int qf_get_fnum(qf_info_T *qi, char_u *directory, char_u *fname) { - char_u *ptr; + char_u *ptr = NULL; + char_u *bufname; buf_T *buf; if (fname == NULL || *fname == NUL) { // no file name return 0; @@ -1314,11 +1320,22 @@ static int 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); + // Use concatenated directory name and file name. + 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; xfree(ptr); } else { - buf = buflist_new(fname, NULL, (linenr_T)0, 0); + 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; } if (buf == NULL) { return 0; |