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/quickfix.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/quickfix.c')
-rw-r--r-- | src/nvim/quickfix.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/nvim/quickfix.c b/src/nvim/quickfix.c index 45982cc68a..259b1b864c 100644 --- a/src/nvim/quickfix.c +++ b/src/nvim/quickfix.c @@ -3734,7 +3734,8 @@ load_dummy_buffer ( ) { buf_T *newbuf; - buf_T *newbuf_to_wipe = NULL; + bufref_T newbufref; + bufref_T newbuf_to_wipe; int failed = TRUE; aco_save_T aco; @@ -3743,6 +3744,7 @@ load_dummy_buffer ( if (newbuf == NULL) { return NULL; } + set_bufref(&newbufref, newbuf); /* Init the options. */ buf_copy_options(newbuf, BCO_ENTER | BCO_NOHELP); @@ -3762,6 +3764,7 @@ load_dummy_buffer ( * work. */ curbuf->b_flags &= ~BF_DUMMY; + newbuf_to_wipe.br_buf = NULL; if (readfile(fname, NULL, (linenr_T)0, (linenr_T)0, (linenr_T)MAXLNUM, NULL, READ_NEW | READ_DUMMY) == OK @@ -3769,19 +3772,19 @@ load_dummy_buffer ( && !(curbuf->b_flags & BF_NEW)) { failed = FALSE; if (curbuf != newbuf) { - /* Bloody autocommands changed the buffer! Can happen when - * using netrw and editing a remote file. Use the current - * buffer instead, delete the dummy one after restoring the - * window stuff. */ - newbuf_to_wipe = newbuf; + // Bloody autocommands changed the buffer! Can happen when + // using netrw and editing a remote file. Use the current + // buffer instead, delete the dummy one after restoring the + // window stuff. + set_bufref(&newbuf_to_wipe, newbuf); newbuf = curbuf; } } // Restore curwin/curbuf and a few other things. aucmd_restbuf(&aco); - if (newbuf_to_wipe != NULL && buf_valid(newbuf_to_wipe)) { - wipe_buffer(newbuf_to_wipe, false); + if (newbuf_to_wipe.br_buf != NULL && bufref_valid(&newbuf_to_wipe)) { + wipe_buffer(newbuf_to_wipe.br_buf, false); } // Add back the "dummy" flag, otherwise buflist_findname_file_id() @@ -3797,8 +3800,9 @@ load_dummy_buffer ( os_dirname(resulting_dir, MAXPATHL); restore_start_dir(dirname_start); - if (!buf_valid(newbuf)) + if (!bufref_valid(&newbufref)) { return NULL; + } if (failed) { wipe_dummy_buffer(newbuf, dirname_start); return NULL; |