Skip to content

Commit

Permalink
Call setline() once with list to improve performance
Browse files Browse the repository at this point in the history
Closes #110
  • Loading branch information
tpope committed Mar 23, 2021
1 parent f8238d7 commit 349340d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugin/commentary.vim
Expand Up @@ -50,6 +50,7 @@ function! s:go(...) abort
let indent = '^\s*'
endif

let lines = []
for lnum in range(lnum1,lnum2)
let line = getline(lnum)
if strlen(r) > 2 && l.r !~# '\\'
Expand All @@ -62,8 +63,9 @@ function! s:go(...) abort
else
let line = substitute(line,'^\%('.matchstr(getline(lnum1),indent).'\|\s*\)\zs.*\S\@<=','\=l.submatch(0).r','')
endif
call setline(lnum,line)
call add(lines, line)
endfor
call setline(lnum1, lines)
let modelines = &modelines
try
set modelines=0
Expand Down

0 comments on commit 349340d

Please sign in to comment.