use 'filter' instead of 'if'

This commit is contained in:
Marco Hinz 2013-03-27 11:06:58 +01:00
parent 1de08cbd9b
commit 0e3e9e9197

View File

@ -225,11 +225,9 @@ function! s:sign_get_others(path) abort
sil! execute 'sign place file='. a:path sil! execute 'sign place file='. a:path
redir END redir END
for line in split(signlist, '\n') for line in filter(split(signlist, '\n'), 'v:val =~ "\v^\s+\w+"')
if line =~ '\v^\s+\w+'
let lnum = matchlist(line, '\v^\s+\w+\=(\d+)')[1] let lnum = matchlist(line, '\v^\s+\w+\=(\d+)')[1]
let s:other_signs_line_numbers[lnum] = 1 let s:other_signs_line_numbers[lnum] = 1
endif
endfor endfor
endfunction endfunction
@ -328,19 +326,10 @@ endfunction
" Functions -> s:repo_process_diff() {{{1 " Functions -> s:repo_process_diff() {{{1
function! s:repo_process_diff(path, diff) abort function! s:repo_process_diff(path, diff) abort
" Determine where we have to put our signs. " Determine where we have to put our signs.
for line in split(a:diff, '\n') for line in filter(split(a:diff, '\n'), 'v:val =~ "^@@"')
" Parse diff output.
if line !~ '^@@'
continue
endif
let tokens = matchlist(line, '^\v\@\@ -(\d+),?(\d*) \+(\d+),?(\d*)') let tokens = matchlist(line, '^\v\@\@ -(\d+),?(\d*) \+(\d+),?(\d*)')
if empty(tokens)
echo 'signify: I cannot parse this line "'. line .'"'
return
endif
let [ old_line, old_count, new_line, new_count ] = [ str2nr(tokens[1]), (tokens[2] == '') ? 1 : str2nr(tokens[2]), str2nr(tokens[3]), (tokens[4] == '') ? 1 : str2nr(tokens[4]) ] let [ old_line, old_count, new_line, new_count ] = [ str2nr(tokens[1]), empty(tokens[2]) ? 1 : str2nr(tokens[2]), str2nr(tokens[3]), empty(tokens[4]) ? 1 : str2nr(tokens[4]) ]
" A new line was added. " A new line was added.
if (old_count == 0) && (new_count >= 1) if (old_count == 0) && (new_count >= 1)