index: skip max trigram check if content is too small (#430)
When viewing profiles for zoekt-git-index on the sourcegraph repo, the
map assignment for the trigram check in CheckText represented 12% of CPU
time. However, we don't need to bother doing this if the files length is
less than the threshold. In particular, a file can contain at most
len(file) - 3 + 1 trigrams.
Here is the change via hyperfine on indexing the sourcegraph repo. I
didn't check via benchmark since I wanted a real world example.
$ hyperfine -w 1 \
'./zoekt-git-index-base -incremental=false -disable_ctags=true .' \
'./zoekt-git-index-trigram -incremental=false -disable_ctags=true .'
..snip..
Summary
'./zoekt-git-index-trigram -incremental=false -disable_ctags=true .' ran
1.10 ± 0.01 times faster than './zoekt-git-index-base -incremental=false -disable_ctags=true .'
Test Plan: go test and manual testing