Prabir Shrestha wrote:
> It is really not about `results[39:49]` but about the `setline`. > > If you merge you need to do this which means it is doing for loop in vimscr= > ipt and is slow. > > ```vim > let i = 1 > for item in results[39:49] > call setline(1, [item[0]]) > let i += 1 > endfor > ``` > > vs > > if you make it different array i can directly use `setline` which means for > loop runs in c and is lot faster. > > ```vim > call setline(1, results[39:49]) > ``` > > Question really should be about how can I call `setline` without using for > loop in vimscript. > > I will most likely just use `call setline(1, items)` and only use > `result[39:49]` for highlights only. There are two different issues. > One is setting the buffer contents and another is highlighting. It is > important to do both efficiently and the current proposed result > doesn't allow that. Having two separate arrays is a bit akward but > seems lot more efficient and faster. I would prefer pref to akwardness > here. Since you are modifying the buffer text, this will take some effort anyway. Once Vim9 script is ready, you can use a :def function where the for loop should be quite fast. Perhaps it also works with a map() function. I've been wondering if it's useful to add a forEach() function. But the overhead of invoking a callback probably makes it slower than a compiled function. -- Why is "abbreviation" such a long word? /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- 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/202009151834.08FIYdcL1961385%40masaka.moolenaar.net.
