----- Original Message ----- From: "A.J.Mechelynck" <[EMAIL PROTECTED]>
To: "Stahlman Family" <[EMAIL PROTECTED]>
Cc: <vim@vim.org>
Sent: Saturday, September 23, 2006 1:59 AM
Subject: Re: Why not use binary search for wildmode tag completion in case of 
fixed-start, non-regex pattern?


Stahlman Family wrote:
Recently, I've begun building tags for a very large development project. The time required by Vim to build the list prior to displaying the first match after I hit wildchar for a :tag command has become noticeably long. I researched it a bit in both the help and the source code, and I'm wondering why Vim always does a linear search for tag completions that could return more than one match. I mean, I understand why in a case like this

:ta /[a-z]_fun<wildchar>

linear search would be necessary. But what about in the much more common case

:ta ProcessA<wildchar>

For such fixed start patterns, all possible matches will be clustered together (and usually will span no more than a handful of lines) in a sorted tags file. Thus, the beginning of the range of possibilities could be found via binary search, then the remaining matches could be found by traversing the tags file linearly until the last match is found. For tags files containing tens of thousands of tags, as mine does, this would result in a dramatic improvement in responsiveness when wildchar is hit.

Thanks,
   Brett Stahlman



Does your tags file start with one of the lines

!_TAG_FILE_SORTED<Tab>1<Tab>{anything}
or
!_TAG_FILE_SORTED<Tab>2<Tab>{anything}

and if yes, which one?

the former
.
And what is the reply to ":verbose set ignorecase"?

ignorecase is off


see ":help tagsrch.txt" then search for /!_TAG_

I know the binary search is being used in cases where only a single match can 
be found.
e.g.,
:ta MyFunc<Enter>

In such cases, the tag location is jumped to practically instantaneously. It is obvious, however, that the linear search is employed when I do something like this instead:
:ta MyFunc<wildchar>

This is in accordance with the help on 'tagbsearch' option:
"This option doesn't affect commands that find all matching tags (e.g.,
command-line completion and ":help")."

I understand why this is done in the case in which the tag pattern being completed is a regex, but it seems to increase the search time significantly and unnecessarily in what I believe is the more common case of a completion on a fixed string pattern.

Thanks,
   Brett Stahlman



Best regards,
Tony.



Reply via email to