Skip to content

Commit 9f8187c

Browse files
committed
patch 7.4.2272
Problem: getbufinfo(), getwininfo() and gettabinfo() are inefficient. Solution: Instead of making a copy of the variables dictionary, use a reference.
1 parent ffdf08c commit 9f8187c

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/evalfunc.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3922,7 +3922,6 @@ get_buffer_info(buf_T *buf)
39223922
{
39233923
dict_T *dict;
39243924
dict_T *opts;
3925-
dict_T *vars;
39263925
tabpage_T *tp;
39273926
win_T *wp;
39283927
list_T *windows;
@@ -3943,10 +3942,8 @@ get_buffer_info(buf_T *buf)
39433942
buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0,
39443943
NULL);
39453944

3946-
/* Copy buffer variables */
3947-
vars = dict_copy(buf->b_vars, TRUE, 0);
3948-
if (vars != NULL)
3949-
dict_add_dict(dict, "variables", vars);
3945+
/* Get a reference to buffer variables */
3946+
dict_add_dict(dict, "variables", buf->b_vars);
39503947

39513948
/* Copy buffer options */
39523949
opts = get_winbuf_options(TRUE);
@@ -4994,7 +4991,6 @@ get_tabpage_info(tabpage_T *tp, int tp_idx)
49944991
{
49954992
win_T *wp;
49964993
dict_T *dict;
4997-
dict_T *vars;
49984994
list_T *l;
49994995

50004996
dict = dict_alloc();
@@ -5012,10 +5008,8 @@ get_tabpage_info(tabpage_T *tp, int tp_idx)
50125008
dict_add_list(dict, "windows", l);
50135009
}
50145010

5015-
/* Copy tabpage variables */
5016-
vars = dict_copy(tp->tp_vars, TRUE, 0);
5017-
if (vars != NULL)
5018-
dict_add_dict(dict, "variables", vars);
5011+
/* Make a reference to tabpage variables */
5012+
dict_add_dict(dict, "variables", tp->tp_vars);
50195013

50205014
return dict;
50215015
}
@@ -5118,7 +5112,6 @@ f_gettabwinvar(typval_T *argvars, typval_T *rettv)
51185112
get_win_info(win_T *wp, short tpnr, short winnr)
51195113
{
51205114
dict_T *dict;
5121-
dict_T *vars;
51225115
dict_T *opts;
51235116

51245117
dict = dict_alloc();
@@ -5138,10 +5131,8 @@ get_win_info(win_T *wp, short tpnr, short winnr)
51385131
(bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL), NULL);
51395132
#endif
51405133

5141-
/* Copy window variables */
5142-
vars = dict_copy(wp->w_vars, TRUE, 0);
5143-
if (vars != NULL)
5144-
dict_add_dict(dict, "variables", vars);
5134+
/* Make a reference to window variables */
5135+
dict_add_dict(dict, "variables", wp->w_vars);
51455136

51465137
/* Copy window options */
51475138
opts = get_winbuf_options(FALSE);

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2272,
766768
/**/
767769
2271,
768770
/**/

0 commit comments

Comments
 (0)