mirror of
https://github.com/itchyny/lightline.vim.git
synced 2025-11-13 14:03:51 -05:00
define and use s:flatten_twice instead of using s:flatten twice for performance
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
" Filename: autoload/lightline.vim
|
" Filename: autoload/lightline.vim
|
||||||
" Author: itchyny
|
" Author: itchyny
|
||||||
" License: MIT License
|
" License: MIT License
|
||||||
" Last Change: 2016/03/22 09:18:07.
|
" Last Change: 2016/03/23 14:12:05.
|
||||||
" =============================================================================
|
" =============================================================================
|
||||||
|
|
||||||
let s:save_cpo = &cpo
|
let s:save_cpo = &cpo
|
||||||
@@ -393,10 +393,12 @@ function! s:convert(name, index) abort
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:flatten(xss) abort
|
function! s:flatten_twice(xss) abort
|
||||||
let ys = []
|
let ys = []
|
||||||
for xs in a:xss
|
for xs in a:xss
|
||||||
let ys += xs
|
for x in xs
|
||||||
|
let ys += x
|
||||||
|
endfor
|
||||||
endfor
|
endfor
|
||||||
return ys
|
return ys
|
||||||
endfunction
|
endfunction
|
||||||
@@ -406,7 +408,7 @@ function! s:expand(components) abort
|
|||||||
let expanded = []
|
let expanded = []
|
||||||
let indices = []
|
let indices = []
|
||||||
let previndex = -1
|
let previndex = -1
|
||||||
let xs = s:flatten(s:flatten(map(deepcopy(a:components), 'map(v:val, "s:convert(v:val, string(" . v:key . "))")')))
|
let xs = s:flatten_twice(map(deepcopy(a:components), 'map(v:val, "s:convert(v:val, string(" . v:key . "))")'))
|
||||||
for [component, expand, index] in xs
|
for [component, expand, index] in xs
|
||||||
if previndex != index
|
if previndex != index
|
||||||
call add(indices, index)
|
call add(indices, index)
|
||||||
|
|||||||
Reference in New Issue
Block a user