From f15d130c3a89aed069980aeec64670b2d4b36eab Mon Sep 17 00:00:00 2001 From: Jan Larres Date: Sun, 23 Jan 2011 15:09:08 +1300 Subject: [PATCH] Speed up child processing by separating scoped from non-scoped tags --- plugin/tagbar.vim | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/plugin/tagbar.vim b/plugin/tagbar.vim index db34d1b..8076af5 100644 --- a/plugin/tagbar.vim +++ b/plugin/tagbar.vim @@ -413,13 +413,23 @@ function! s:ProcessFile(fname, ftype) endfor if has_key(typeinfo, 'scopes') && !empty(typeinfo.scopes) - let processedtags = [] - + let scopedtags = [] for scope in typeinfo.scopes - call s:AddChildren(fileinfo.tags, processedtags, '', + let is_scoped = 'has_key(typeinfo.kind2scope, v:val.fields.kind) || + \ has_key(v:val.fields, scope)' + let scopedtags += filter(copy(fileinfo.tags), is_scoped) + call filter(fileinfo.tags, '!(' . is_scoped . ')') + endfor + + let processedtags = [] + for scope in typeinfo.scopes + call s:AddChildren(scopedtags, processedtags, '', \ '', scope, 1, typeinfo) endfor + " 'scopedtags' can still contain some tags that don't have any + " children + call extend(fileinfo.tags, scopedtags) call extend(fileinfo.tags, processedtags) endif