diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-07-10 17:00:38 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-07-10 17:00:38 +0200 |
commit | 8240433f48f7383c281ba2453cc55f10b8ec47d9 (patch) | |
tree | 6b70e050976645909c15236df272ab9f61672e14 /src/quickfix.c | |
parent | 2bc127f94016801250f8f24234f90a5182d77e73 (diff) | |
download | vim-git-8240433f48f7383c281ba2453cc55f10b8ec47d9.tar.gz |
patch 7.4.2017v7.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.
Diffstat (limited to 'src/quickfix.c')
-rw-r--r-- | src/quickfix.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/src/quickfix.c b/src/quickfix.c index 92a020417..065216afe 100644 --- a/src/quickfix.c +++ b/src/quickfix.c @@ -1483,14 +1483,22 @@ 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; + +/* * Get buffer number for file "dir.name". * 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; 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; } |