Christian Brabandt wrote:

> I recently noticed, using <nr>ifoobar<esc> can slow down vim 
> considerably for large numbers. This gets even more apparent when using 
> multibyte characters.
> 
> This happens, because getvcol() gets called several times for each 
> entered character and this will get worse for each entered character, 
> since Vim needs to loop for each entered character over the complete 
> line again to update the virtual column.
> 
> Here is a patch, that improves this a little bit, by making sure, that 
> saves a call to the getvvcol() function and does only call 
> update_topline and a couple of similar functions when the count is 1.
> 
> Here is a small benchmark using that patch:
> time vim -u NONE -N -c ':exe "norm! <nr>afoobar\<esc>:q!\<cr>"'
> 
> <nr>         Vim         Patch
> 1000         3,6s        1,6s
> 2000        18,4s        6,4s
> 2500        29,5s       10,1s
> (I didn't even try to use some really large <nr>)
> 
> As you can see, this seems to slow down exponentially. I could imagine,
> that this will make Vim unresponsive even when not using <nr>a but one 
> only tries to append to a real long line.
> 
> I think, one could further improve that, by caching the virtual column 
> and not to start counting again from the beginning of a line for each 
> entered character. But this is more complicated.

Thanks, I'll add it in the todo list.
In the mean time, feel free to improve it further.


-- 
Q: What is a patch 22?
A: A patch you need to include to make it possible to include patches.

 /// 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].
For more options, visit https://groups.google.com/groups/opt_out.

Raspunde prin e-mail lui