aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/eval.c
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2016-12-12 23:01:53 -0500
committerJames McCoy <jamessan@jamessan.com>2016-12-28 14:57:39 -0500
commitfe03ce23bfc5c45545b53d4959aeeb27d82753ed (patch)
treebdd8a620471f3529d8171e8e5e989d2552424dc7 /src/nvim/eval.c
parent03ed7e1ebaf7f0934b176c71949a77a3fe2291fb (diff)
downloadrneovim-fe03ce23bfc5c45545b53d4959aeeb27d82753ed.tar.gz
rneovim-fe03ce23bfc5c45545b53d4959aeeb27d82753ed.tar.bz2
rneovim-fe03ce23bfc5c45545b53d4959aeeb27d82753ed.zip
vim-patch:7.4.2273
Problem: getwininfo() and getbufinfo() are inefficient. Solution: Do not make a copy of all window/buffer-local options. Make it possible to get them with gettabwinvar() or getbufvar(). https://github.com/vim/vim/commit/3056735ae8a366aa7fcb51872520895251858637
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r--src/nvim/eval.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 59d1132c79..2b325bbf20 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -9883,12 +9883,6 @@ static dict_T *get_buffer_info(buf_T *buf)
// Get a reference to buffer variables
dict_add_dict(dict, "variables", buf->b_vars);
- // Copy buffer options
- dict_T *opts = get_winbuf_options(true);
- if (opts != NULL) {
- dict_add_dict(dict, "options", opts);
- }
-
// List of windows displaying this buffer
list_T *windows = list_alloc();
FOR_ALL_TAB_WINDOWS(tp, wp) {
@@ -10056,8 +10050,20 @@ static void f_getbufvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
curbuf = buf;
if (*varname == '&') { /* buffer-local-option */
- if (get_option_tv(&varname, rettv, TRUE) == OK)
+ if (varname[1] == NUL) {
+ // get all buffer-local options in a dict
+ dict_T *opts = get_winbuf_options(true);
+
+ if (opts != NULL) {
+ rettv->v_type = VAR_DICT;
+ rettv->vval.v_dict = opts;
+ opts->dv_refcount++;
+ done = true;
+ }
+ } else if (get_option_tv(&varname, rettv, true) == OK) {
+ // buffer-local-option
done = TRUE;
+ }
} else if (STRCMP(varname, "changedtick") == 0) {
rettv->v_type = VAR_NUMBER;
rettv->vval.v_number = curbuf->b_changedtick;
@@ -10904,15 +10910,9 @@ static dict_T *get_win_info(win_T *wp, short tpnr, short winnr)
(bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL),
NULL);
- // Make a reference to window variables
+ // Add a reference to window variables
dict_add_dict(dict, "variables", wp->w_vars);
- // Copy window options
- dict_T *opts = get_winbuf_options(false);
- if (opts != NULL) {
- dict_add_dict(dict, "options", opts);
- }
-
return dict;
}
@@ -11072,8 +11072,19 @@ getwinvar (
bool need_switch_win = tp != curtab || win != curwin;
if (!need_switch_win
|| switch_win(&oldcurwin, &oldtabpage, win, tp, true) == OK) {
- if (*varname == '&') { // window-local-option
- if (get_option_tv(&varname, rettv, 1) == OK) {
+ if (*varname == '&') {
+ if (varname[1] == NUL) {
+ // get all window-local options in a dict
+ dict_T *opts = get_winbuf_options(false);
+
+ if (opts != NULL) {
+ rettv->v_type = VAR_DICT;
+ rettv->vval.v_dict = opts;
+ opts->dv_refcount++;
+ done = true;
+ }
+ } else if (get_option_tv(&varname, rettv, 1) == OK) {
+ // window-local-option
done = true;
}
} else {