Skip to content

Commit

Permalink
Merge pull request Shougo#146 from ichizok/improve-system
Browse files Browse the repository at this point in the history
Improved s:system performance
  • Loading branch information
Shougo committed Jun 15, 2014
2 parents 1e3492c + 477866b commit 4ade77b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions autoload/vimproc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,9 @@ function! s:system(cmdline, is_passwd, input, timeout, is_pty) "{{{
call subproc.stdin.close()
endif

let output = ''
let s:last_errmsg = ''
let outbuf = []
let errbuf = []
while !subproc.stdout.eof || !subproc.stderr.eof
if timeout > 0 "{{{
" Check timeout.
Expand All @@ -258,7 +259,7 @@ function! s:system(cmdline, is_passwd, input, timeout, is_pty) "{{{
endif"}}}

if !subproc.stdout.eof "{{{
let out = subproc.stdout.read(1000, 0)
let out = subproc.stdout.read(10000, 10)

if a:is_passwd && out =~# g:vimproc_password_pattern
redraw
Expand All @@ -271,12 +272,12 @@ function! s:system(cmdline, is_passwd, input, timeout, is_pty) "{{{

call subproc.stdin.write(in)
else
let output .= out
let outbuf += [out]
endif
endif"}}}

if !subproc.stderr.eof "{{{
let out = subproc.stderr.read(1000, 0)
let out = subproc.stderr.read(10000, 10)

if a:is_passwd && out =~# g:vimproc_password_pattern
redraw
Expand All @@ -289,12 +290,15 @@ function! s:system(cmdline, is_passwd, input, timeout, is_pty) "{{{

call subproc.stdin.write(in)
else
let s:last_errmsg .= out
let output .= out
let outbuf += [out]
let errbuf += [out]
endif
endif"}}}
endwhile

let output = join(outbuf, '')
let s:last_errmsg = join(errbuf, '')

let [cond, status] = subproc.waitpid()

" Newline convert.
Expand Down

0 comments on commit 4ade77b

Please sign in to comment.