make rtpath an attribute

- having it as a function makes it slower
This commit is contained in:
gmarik 2012-01-28 18:05:21 -06:00
parent eb6e676d3e
commit 1fce719532
2 changed files with 11 additions and 8 deletions

View File

@ -14,7 +14,7 @@ endf
func! vundle#config#require(bundles) abort
for b in a:bundles
call s:rtp_add(b.rtpath())
call s:rtp_add(b.rtpath)
call s:rtp_add(g:bundle_dir)
" TODO: it has to be relative rtpath, not bundle.name
exec 'runtime! '.b.name.'/plugin/*.vim'
@ -25,7 +25,9 @@ endf
func! vundle#config#init_bundle(name, opts)
let opts = extend(s:parse_options(a:opts), s:parse_name(substitute(a:name,"['".'"]\+','','g')))
return extend(opts, copy(s:bundle))
let b = extend(opts, copy(s:bundle))
let b.rtpath = s:rtpath(opts)
return b
endf
func! s:parse_options(opts)
@ -63,11 +65,11 @@ func! s:parse_name(arg)
endf
func! s:rtp_rm_a()
call filter(copy(g:bundles), 's:rtp_rm(v:val.rtpath())')
call filter(copy(g:bundles), 's:rtp_rm(v:val.rtpath)')
endf
func! s:rtp_add_a()
call filter(reverse(copy(g:bundles)), 's:rtp_add(v:val.rtpath())')
call filter(reverse(copy(g:bundles)), 's:rtp_add(v:val.rtpath)')
endf
func! s:rtp_rm(dir) abort
@ -84,12 +86,13 @@ func! s:expand_path(path) abort
return simplify(expand(a:path, 1))
endf
func! s:rtpath(opts)
return has_key(a:opts, 'rtp') ? s:expand_path(a:opts.path().'/'.a:opts.rtp) : a:opts.path()
endf
let s:bundle = {}
func! s:bundle.path()
return s:expand_path(g:bundle_dir.'/'.self.name)
endf
func! s:bundle.rtpath()
return has_key(self, 'rtp') ? s:expand_path(self.path().'/'.self.rtp) : self.path()
endf

View File

@ -103,7 +103,7 @@ func! vundle#installer#docs() abort
endf
func! vundle#installer#helptags(bundles) abort
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath()')
let bundle_dirs = map(copy(a:bundles),'v:val.rtpath')
let help_dirs = filter(bundle_dirs, 's:has_doc(v:val)')
call s:log('')