0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 8.2.1775: MS-Windows: adding a long quickfix list is slow

Problem:    MS-Windows: adding a long quickfix list is slow.
Solution:   Shorten the buffer name only for the first entry. (Yegappan
            Lakshmanan, closes #7039, closes #7033)
This commit is contained in:
Bram Moolenaar
2020-09-29 22:47:03 +02:00
parent 32fbc4f247
commit 8ec92c9779
3 changed files with 24 additions and 4 deletions

View File

@@ -4496,6 +4496,7 @@ qf_buf_add_line(
linenr_T lnum, linenr_T lnum,
qfline_T *qfp, qfline_T *qfp,
char_u *dirname, char_u *dirname,
int first_bufline,
char_u *qftf_str) char_u *qftf_str)
{ {
int len; int len;
@@ -4520,9 +4521,11 @@ qf_buf_add_line(
vim_strncpy(IObuff, gettail(errbuf->b_fname), IOSIZE - 1); vim_strncpy(IObuff, gettail(errbuf->b_fname), IOSIZE - 1);
else else
{ {
// shorten the file name if not done already // Shorten the file name if not done already.
if (errbuf->b_sfname == NULL // For optimization, do this only for the first entry in a
|| mch_isFullName(errbuf->b_sfname)) // buffer.
if (first_bufline && (errbuf->b_sfname == NULL
|| mch_isFullName(errbuf->b_sfname)))
{ {
if (*dirname == NUL) if (*dirname == NUL)
mch_dirname(dirname, MAXPATHL); mch_dirname(dirname, MAXPATHL);
@@ -4663,6 +4666,7 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
{ {
char_u dirname[MAXPATHL]; char_u dirname[MAXPATHL];
int invalid_val = FALSE; int invalid_val = FALSE;
int prev_bufnr = -1;
*dirname = NUL; *dirname = NUL;
@@ -4697,9 +4701,11 @@ qf_fill_buffer(qf_list_T *qfl, buf_T *buf, qfline_T *old_last, int qf_winid)
invalid_val = TRUE; invalid_val = TRUE;
} }
if (qf_buf_add_line(buf, lnum, qfp, dirname, qftf_str) == FAIL) if (qf_buf_add_line(buf, lnum, qfp, dirname,
prev_bufnr != qfp->qf_fnum, qftf_str) == FAIL)
break; break;
prev_bufnr = qfp->qf_fnum;
++lnum; ++lnum;
qfp = qfp->qf_next; qfp = qfp->qf_next;
if (qfp == NULL) if (qfp == NULL)

View File

@@ -3996,6 +3996,18 @@ func Test_shorten_fname()
" Displaying the quickfix list should simplify the file path " Displaying the quickfix list should simplify the file path
silent! clist silent! clist
call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim')) call assert_equal('test_quickfix.vim', bufname('test_quickfix.vim'))
" Add a few entries for the same file with different paths and check whether
" the buffer name is shortened
%bwipe
call setqflist([], 'f')
call setqflist([{'filename' : 'test_quickfix.vim', 'lnum' : 10},
\ {'filename' : '../testdir/test_quickfix.vim', 'lnum' : 20},
\ {'filename' : fname, 'lnum' : 30}], ' ')
copen
call assert_equal(['test_quickfix.vim|10| ',
\ 'test_quickfix.vim|20| ',
\ 'test_quickfix.vim|30| '], getline(1, '$'))
cclose
endfunc endfunc
" Quickfix title tests " Quickfix title tests

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1775,
/**/ /**/
1774, 1774,
/**/ /**/