# HG changeset patch # User Christian Brabandt # Date 1472323505 -7200 # Node ID 3063d1acd0c968248b0621f0552cc2043d86645e # Parent 872a7f55d59ac1e74734c58db8531fa2cf585199 commit https://github.com/vim/vim/commit/9f8187c335b4fb07be9095dfdd0fc52670ba3c3f Author: Bram Moolenaar Date: Sat Aug 27 20:34:01 2016 +0200 patch 7.4.2272 Problem: getbufinfo(), getwininfo() and gettabinfo() are inefficient. Solution: Instead of making a copy of the variables dictionary, use a reference. diff --git a/src/evalfunc.c b/src/evalfunc.c --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -3922,7 +3922,6 @@ get_buffer_info(buf_T *buf) { dict_T *dict; dict_T *opts; - dict_T *vars; tabpage_T *tp; win_T *wp; list_T *windows; @@ -3943,10 +3942,8 @@ get_buffer_info(buf_T *buf) buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0, NULL); - /* Copy buffer variables */ - vars = dict_copy(buf->b_vars, TRUE, 0); - if (vars != NULL) - dict_add_dict(dict, "variables", vars); + /* Get a reference to buffer variables */ + dict_add_dict(dict, "variables", buf->b_vars); /* Copy buffer options */ opts = get_winbuf_options(TRUE); @@ -4994,7 +4991,6 @@ get_tabpage_info(tabpage_T *tp, int tp_i { win_T *wp; dict_T *dict; - dict_T *vars; list_T *l; dict = dict_alloc(); @@ -5012,10 +5008,8 @@ get_tabpage_info(tabpage_T *tp, int tp_i dict_add_list(dict, "windows", l); } - /* Copy tabpage variables */ - vars = dict_copy(tp->tp_vars, TRUE, 0); - if (vars != NULL) - dict_add_dict(dict, "variables", vars); + /* Make a reference to tabpage variables */ + dict_add_dict(dict, "variables", tp->tp_vars); return dict; } @@ -5118,7 +5112,6 @@ f_gettabwinvar(typval_T *argvars, typval get_win_info(win_T *wp, short tpnr, short winnr) { dict_T *dict; - dict_T *vars; dict_T *opts; dict = dict_alloc(); @@ -5138,10 +5131,8 @@ get_win_info(win_T *wp, short tpnr, shor (bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL), NULL); #endif - /* Copy window variables */ - vars = dict_copy(wp->w_vars, TRUE, 0); - if (vars != NULL) - dict_add_dict(dict, "variables", vars); + /* Make a reference to window variables */ + dict_add_dict(dict, "variables", wp->w_vars); /* Copy window options */ opts = get_winbuf_options(FALSE); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2272, +/**/ 2271, /**/ 2270,