Hi, On Sun, Jun 7, 2020 at 2:30 AM lacygoill <[email protected]> wrote:
> @yegappan <https://github.com/yegappan> Thank you for working on this > feature. > > The more entries a quickfix list contains, the more costly the > 'quickfixtextfunc' seems to be. > > I tried to write what seems to be a simple function: > > fu QuickFixTextFunc(info) abort > > if a:info.quickfix > > let e = getqflist({'id': a:info.id, 'idx': a:info.idx, 'items': > 1}).items[0] > > else > > let e = getloclist(0, {'id': a:info.id, 'idx': a:info.idx, 'items': > 1}).items[0] > > Note that there is currently an issue with using '0' for the window number. This function will fail if you update the location list after opening and closing the location list window. (lexpr, lwindow, lclose, lexpr). I will create a PR to address this. > > endif > > let fname = fnamemodify(bufname(e.bufnr), ':t') > > if strchars(fname, 1) <= 8 > > let fname = printf('%8s', fname) > > else > > let fname = printf('%.7s', fname)..'…' > > endif > > let lnum = printf('%5d', e.lnum) > > let col = printf('%3d', e.col) > > return fname..'|'..lnum..' col '..col..'| '..e.text > > endfu > > > And tested it with this command: > > $ vim -Nu NONE -S <(curl -Ls > https://gist.githubusercontent.com/lacygoill/57d3cd8b5313159f42af43704ebfa7a8/raw/a255cbc37efe18319690943129d0abdf661c1434/profile_quickfixtextfunc.vim) > > > :QfTf 8 > > > On my machine, the test took about 2 minutes to complete. Here are the > results: > > 1000 entries: 0.001 seconds to run :copen > > 0.039 seconds to run :copen with 'qftf' 39 times slower > > 2000 entries: 0.001 seconds to run :copen > > 0.084 seconds to run :copen with 'qftf' 84 times slower > > 4000 entries: 0.003 seconds to run :copen > > 0.190 seconds to run :copen with 'qftf' 63 times slower > > 8000 entries: 0.006 seconds to run :copen > > 0.457 seconds to run :copen with 'qftf' 76 times slower > > 16000 entries: 0.012 seconds to run :copen > > 1.260 seconds to run :copen with 'qftf' 105 times slower > > 32000 entries: 0.025 seconds to run :copen > > 4.983 seconds to run :copen with 'qftf' 199 times slower > > 64000 entries: 0.054 seconds to run :copen > > 23.322 seconds to run :copen with 'qftf' 431 times slower > > 128000 entries: 0.107 seconds to run :copen > > 97.002 seconds to run :copen with 'qftf' 906 times slower > > > As you can see, for a quickfix list with more than a thousand entries, > 'quickfixtextfunc' makes :copen around a thousand times slower. And the > more entries, the slower the feature is. > > Do you think something could be done to prevent the function from being > called when the quickfix list contains too many entries? Maybe the option > could be set to a colon separated list of values: the name of the function > to format the entry in the quickfix window, and an optional number. When > the size of a quickfix list goes beyond that number, the function would not > be invoked to format the entry. It would be displayed as if the option was > not set. > > > We may not be able to predict the size of the quickfix list beforehand. For example, an async plugin (running ripgrep for example), can incrementally add the search results to the quickfix list. Initially the quickfix list may have a few hundred entries, but as the plugin function asynchronously adds entries to the list, it may grow to a few thousand entries. If the quickfix window is open when the plugin runs, then the first few entries will use the 'qftf' function to format the output, but the later lines will look different. - Yegappan -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/CAAW7x7mdqRD_Yoj3%2BPeM%2BJ8qQ7L0tKQzRCo%3Dx6nSdzaqhues8A%40mail.gmail.com.
