Skip to content

Commit 349340d

Browse files
committed
Call setline() once with list to improve performance
Closes #110
1 parent f8238d7 commit 349340d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

plugin/commentary.vim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ function! s:go(...) abort
5050
let indent = '^\s*'
5151
endif
5252

53+
let lines = []
5354
for lnum in range(lnum1,lnum2)
5455
let line = getline(lnum)
5556
if strlen(r) > 2 && l.r !~# '\\'
@@ -62,8 +63,9 @@ function! s:go(...) abort
6263
else
6364
let line = substitute(line,'^\%('.matchstr(getline(lnum1),indent).'\|\s*\)\zs.*\S\@<=','\=l.submatch(0).r','')
6465
endif
65-
call setline(lnum,line)
66+
call add(lines, line)
6667
endfor
68+
call setline(lnum1, lines)
6769
let modelines = &modelines
6870
try
6971
set modelines=0

0 commit comments

Comments
 (0)