From 6a5fbabe485e673ffb4c7e8aaba77534ad3c671a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 18 Nov 2022 20:03:29 +0800 Subject: [PATCH] vim-patch:8.2.4553: linear tag search is a bit slow Problem: Linear tag search is a bit slow. Solution: Remove a vim_ftell() call. (Yegappan Lakshmanan, closes vim/vim#9937) https://github.com/vim/vim/commit/8b530b3158cbd3aee2ad9cad8e7b7964faabb51e Co-authored-by: Yegappan Lakshmanan --- src/nvim/tag.c | 3 +-- src/nvim/testdir/test_taglist.vim | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/nvim/tag.c b/src/nvim/tag.c index c5df68d451..429dd191b7 100644 --- a/src/nvim/tag.c +++ b/src/nvim/tag.c @@ -1609,7 +1609,6 @@ static tags_read_status_T findtags_get_next_line(findtags_state_T *st, tagsearch // skip empty and blank lines do { - sinfo_p->curr_offset = vim_ftell(st->fp); eof = vim_fgets((char_u *)st->lbuf, st->lbuf_size, st->fp); } while (!eof && vim_isblankline(st->lbuf)); @@ -2161,7 +2160,7 @@ line_read_in: xfree(st->lbuf); st->lbuf = xmalloc((size_t)st->lbuf_size); - if (st->state == TS_STEP_FORWARD) { + if (st->state == TS_STEP_FORWARD || st->state == TS_LINEAR) { // Seek to the same position to read the same line again vim_ignored = vim_fseek(st->fp, search_info.curr_offset, SEEK_SET); } diff --git a/src/nvim/testdir/test_taglist.vim b/src/nvim/testdir/test_taglist.vim index 1a3d1986bf..0387ef2bd8 100644 --- a/src/nvim/testdir/test_taglist.vim +++ b/src/nvim/testdir/test_taglist.vim @@ -264,8 +264,15 @@ func Test_tag_complete_with_overlong_line() call writefile(tagslines, 'Xtags') set tags=Xtags + " try with binary search + set tagbsearch call feedkeys(":tag inbou\\\"\", 'xt') call assert_equal('"tag inboundGSV inboundGovernor inboundGovernorCounters', @:) + " try with linear search + set notagbsearch + call feedkeys(":tag inbou\\\"\", 'xt') + call assert_equal('"tag inboundGSV inboundGovernor inboundGovernorCounters', @:) + set tagbsearch& call delete('Xtags') set tags&