From 276106d987a8fa7bad9f733fc5552ade4cef38b8 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 29 Jul 2014 02:11:59 +0900 Subject: [PATCH] Performance tuning: reduce the number of s:parse_options calls --- plug.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plug.vim b/plug.vim index cd4b4a1..615c1f1 100644 --- a/plug.vim +++ b/plug.vim @@ -71,6 +71,7 @@ let s:plug_buf = -1 let s:mac_gui = has('gui_macvim') && has('gui_running') let s:is_win = has('win32') || has('win64') let s:me = expand(':p') +let s:base_spec = { 'branch': 'master', 'frozen': 0, 'local': 0 } let s:TYPE = { \ 'string': type(""), \ 'list': type([]), @@ -310,7 +311,7 @@ function! s:add(force, repo, ...) return endif - let spec = extend(s:parse_options(a:0 == 1 ? a:1 : {}), + let spec = extend(a:0 == 1 ? s:parse_options(a:1) : copy(s:base_spec), \ s:infer_properties(name, repo)) if !a:force let s:extended[name] = spec @@ -324,7 +325,7 @@ function! s:add(force, repo, ...) endfunction function! s:parse_options(arg) - let opts = { 'branch': 'master', 'frozen': 0, 'local': 0 } + let opts = copy(s:base_spec) let type = type(a:arg) if type == s:TYPE.string let opts.branch = a:arg