Christian Brabandt <
cbl...@256bit.org> wrote:
> Bram,
>
> 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.