diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2017-01-09 14:35:04 +0100 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2017-02-04 17:55:46 -0500 |
commit | c05e7f0fdd15d550cfb1054416a08d4514a4fb7e (patch) | |
tree | ac051f64de7006efe1463da9e549e7c507817683 /src/nvim/ex_getln.c | |
parent | e3b92c77da0277c8d58e037e42c5b929be469284 (diff) | |
download | rneovim-c05e7f0fdd15d550cfb1054416a08d4514a4fb7e.tar.gz rneovim-c05e7f0fdd15d550cfb1054416a08d4514a4fb7e.tar.bz2 rneovim-c05e7f0fdd15d550cfb1054416a08d4514a4fb7e.zip |
vim-patch:7.4.2024
Problem: More buf_valid() calls can be optimized.
Solution: Use bufref_valid() instead.
NOTE: Some changes related to channels and the Python and Netbeans interfaces
were obviously left out.
https://github.com/vim/vim/commit/7c0a2f367f2507669560b1a66423155c70d2e75b
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index dba7a73814..2555b64dfd 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -5134,9 +5134,9 @@ int cmd_gchar(int offset) static int ex_window(void) { struct cmdline_info save_ccline; - buf_T *old_curbuf = curbuf; + bufref_T old_curbuf; + bufref_T bufref; win_T *old_curwin = curwin; - buf_T *bp; win_T *wp; int i; linenr_T lnum; @@ -5155,6 +5155,8 @@ static int ex_window(void) return K_IGNORE; } + set_bufref(&old_curbuf, curbuf); + /* Save current window sizes. */ win_size_save(&winsizes); @@ -5269,7 +5271,7 @@ static int ex_window(void) /* Safety check: The old window or buffer was deleted: It's a bug when * this happens! */ - if (!win_valid(old_curwin) || !buf_valid(old_curbuf)) { + if (!win_valid(old_curwin) || !bufref_valid(&old_curbuf)) { cmdwin_result = Ctrl_C; EMSG(_("E199: Active window or buffer deleted")); } else { @@ -5320,14 +5322,15 @@ static int ex_window(void) // Avoid command-line window first character being concealed curwin->w_p_cole = 0; wp = curwin; - bp = curbuf; + set_bufref(&bufref, curbuf); win_goto(old_curwin); win_close(wp, TRUE); - /* win_close() may have already wiped the buffer when 'bh' is - * set to 'wipe' */ - if (buf_valid(bp)) - close_buffer(NULL, bp, DOBUF_WIPE, FALSE); + // win_close() may have already wiped the buffer when 'bh' is + // set to 'wipe'. + if (bufref_valid(&bufref)) { + close_buffer(NULL, bufref.br_buf, DOBUF_WIPE, false); + } /* Restore window sizes. */ win_size_restore(&winsizes); |