From 1fce719532187aab5c83ab9cd3e5a675edc54201 Mon Sep 17 00:00:00 2001 From: gmarik Date: Sat, 28 Jan 2012 18:05:21 -0600 Subject: [PATCH] make rtpath an attribute - having it as a function makes it slower --- autoload/vundle/config.vim | 17 ++++++++++------- autoload/vundle/installer.vim | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/autoload/vundle/config.vim b/autoload/vundle/config.vim index ee1e42b..fd80cff 100644 --- a/autoload/vundle/config.vim +++ b/autoload/vundle/config.vim @@ -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 diff --git a/autoload/vundle/installer.vim b/autoload/vundle/installer.vim index 0f71ebf..e2a8291 100644 --- a/autoload/vundle/installer.vim +++ b/autoload/vundle/installer.vim @@ -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('')