Mercurial > vim
diff src/buffer.c @ 31600:f1d5ad2b978e v9.0.1132
patch 9.0.1132: code is indented more than needed
Commit: https://github.com/vim/vim/commit/dc4daa3a3915fba11ac87d27977240d9a5e0d47d
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Mon Jan 2 16:54:53 2023 +0000
patch 9.0.1132: code is indented more than needed
Problem: Code is indented more than needed.
Solution: Use an early return to reduce indentation. (Yegappan Lakshmanan,
closes #11769)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 02 Jan 2023 18:00:04 +0100 |
parents | bb797331e21b |
children | 1102f4777518 |
line wrap: on
line diff
--- a/src/buffer.c +++ b/src/buffer.c @@ -146,19 +146,19 @@ read_buffer( void buffer_ensure_loaded(buf_T *buf) { - if (buf->b_ml.ml_mfp == NULL) + if (buf->b_ml.ml_mfp != NULL) + return; + + aco_save_T aco; + + // Make sure the buffer is in a window. If not then skip it. + aucmd_prepbuf(&aco, buf); + if (curbuf == buf) { - aco_save_T aco; - - // Make sure the buffer is in a window. If not then skip it. - aucmd_prepbuf(&aco, buf); - if (curbuf == buf) - { - if (swap_exists_action != SEA_READONLY) - swap_exists_action = SEA_NONE; - open_buffer(FALSE, NULL, 0); - aucmd_restbuf(&aco); - } + if (swap_exists_action != SEA_READONLY) + swap_exists_action = SEA_NONE; + open_buffer(FALSE, NULL, 0); + aucmd_restbuf(&aco); } } #endif @@ -3582,18 +3582,18 @@ buf_set_name(int fnum, char_u *name) buf_T *buf; buf = buflist_findnr(fnum); - if (buf != NULL) - { - if (buf->b_sfname != buf->b_ffname) - vim_free(buf->b_sfname); - vim_free(buf->b_ffname); - buf->b_ffname = vim_strsave(name); - buf->b_sfname = NULL; - // Allocate ffname and expand into full path. Also resolves .lnk - // files on Win32. - fname_expand(buf, &buf->b_ffname, &buf->b_sfname); - buf->b_fname = buf->b_sfname; - } + if (buf == NULL) + return; + + if (buf->b_sfname != buf->b_ffname) + vim_free(buf->b_sfname); + vim_free(buf->b_ffname); + buf->b_ffname = vim_strsave(name); + buf->b_sfname = NULL; + // Allocate ffname and expand into full path. Also resolves .lnk + // files on Win32. + fname_expand(buf, &buf->b_ffname, &buf->b_sfname); + buf->b_fname = buf->b_sfname; } /* @@ -5921,14 +5921,14 @@ buf_get_fname(buf_T *buf) void set_buflisted(int on) { - if (on != curbuf->b_p_bl) - { - curbuf->b_p_bl = on; - if (on) - apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf); - else - apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf); - } + if (on == curbuf->b_p_bl) + return; + + curbuf->b_p_bl = on; + if (on) + apply_autocmds(EVENT_BUFADD, NULL, NULL, FALSE, curbuf); + else + apply_autocmds(EVENT_BUFDELETE, NULL, NULL, FALSE, curbuf); } /*