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.
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.
Best
Christian
--
--
--
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.
diff --git a/src/edit.c b/src/edit.c
--- a/src/edit.c
+++ b/src/edit.c
@@ -692,7 +692,7 @@
)
{
mincol = curwin->w_wcol;
- validate_cursor_col();
+ /* validate_cursor_col(); */
if ((int)curwin->w_wcol < mincol - curbuf->b_p_ts
&& curwin->w_wrow == W_WINROW(curwin)
@@ -717,18 +717,20 @@
}
}
+ did_backspace = FALSE;
/* May need to adjust w_topline to show the cursor. */
- update_topline();
-
- did_backspace = FALSE;
-
- validate_cursor(); /* may set must_redraw */
-
- /*
- * Redraw the display when no characters are waiting.
- * Also shows mode, ruler and positions cursor.
- */
- ins_redraw(TRUE);
+ if (count <= 1)
+ {
+ update_topline();
+ validate_cursor(); /* may set must_redraw */
+ /*
+ * Redraw the display when no characters are waiting.
+ * Also shows mode, ruler and positions cursor.
+ */
+ ins_redraw(TRUE);
+ }
+
+
#ifdef FEAT_SCROLLBIND
if (curwin->w_p_scb)
@@ -755,7 +757,7 @@
lastc = c; /* remember previous char for CTRL-D */
do
{
- c = safe_vgetc();
+ c = safe_vgetc(); /* calls getvvcol */
} while (c == K_IGNORE);
#ifdef FEAT_AUTOCMD