aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-01-26 21:05:34 +0800
committerGitHub <noreply@github.com>2023-01-26 21:05:34 +0800
commit41aa5ce3eb49705d26137ac2b34f5ad7cd43f2cf (patch)
treedf684f027501b9c419841cc2d03cfb69008e494d
parente02df23b4e24046d99c7bfa6a63b4db16c28a7be (diff)
downloadrneovim-41aa5ce3eb49705d26137ac2b34f5ad7cd43f2cf.tar.gz
rneovim-41aa5ce3eb49705d26137ac2b34f5ad7cd43f2cf.tar.bz2
rneovim-41aa5ce3eb49705d26137ac2b34f5ad7cd43f2cf.zip
vim-patch:9.0.1246: code is indented more than necessary (#22006)
Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes vim/vim#11887) https://github.com/vim/vim/commit/142ed77898facf8f423fee2717efee1749c55f9a Omit function_using_block_scopes(): only affects Vim9 script. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
-rw-r--r--src/nvim/eval/userfunc.c9
-rw-r--r--src/nvim/undo.c8
-rw-r--r--src/nvim/window.c30
3 files changed, 26 insertions, 21 deletions
diff --git a/src/nvim/eval/userfunc.c b/src/nvim/eval/userfunc.c
index 22c5b1954d..6c6dc3fa43 100644
--- a/src/nvim/eval/userfunc.c
+++ b/src/nvim/eval/userfunc.c
@@ -760,13 +760,12 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force)
static bool func_remove(ufunc_T *fp)
{
hashitem_T *hi = hash_find(&func_hashtab, (char *)UF2HIKEY(fp));
-
- if (!HASHITEM_EMPTY(hi)) {
- hash_remove(&func_hashtab, hi);
- return true;
+ if (HASHITEM_EMPTY(hi)) {
+ return false;
}
- return false;
+ hash_remove(&func_hashtab, hi);
+ return true;
}
static void func_clear_items(ufunc_T *fp)
diff --git a/src/nvim/undo.c b/src/nvim/undo.c
index 2b0bb1d243..0f12c00f15 100644
--- a/src/nvim/undo.c
+++ b/src/nvim/undo.c
@@ -2985,10 +2985,12 @@ void u_saveline(linenr_T lnum)
/// (this is used externally for crossing a line while in insert mode)
void u_clearline(void)
{
- if (curbuf->b_u_line_ptr != NULL) {
- XFREE_CLEAR(curbuf->b_u_line_ptr);
- curbuf->b_u_line_lnum = 0;
+ if (curbuf->b_u_line_ptr == NULL) {
+ return;
}
+
+ XFREE_CLEAR(curbuf->b_u_line_ptr);
+ curbuf->b_u_line_lnum = 0;
}
/// Implementation of the "U" command.
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 05f84b5a91..6b40ccdb84 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -2599,6 +2599,7 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, tabpage_T *prev
if (!ONE_WINDOW) {
return false;
}
+
buf_T *old_curbuf = curbuf;
Terminal *term = win->w_buffer ? win->w_buffer->terminal : NULL;
@@ -4144,12 +4145,13 @@ int may_open_tabpage(void)
{
int n = (cmdmod.cmod_tab == 0) ? postponed_split_tab : cmdmod.cmod_tab;
- if (n != 0) {
- cmdmod.cmod_tab = 0; // reset it to avoid doing it twice
- postponed_split_tab = 0;
- return win_new_tabpage(n, NULL);
+ if (n == 0) {
+ return FAIL;
}
- return FAIL;
+
+ cmdmod.cmod_tab = 0; // reset it to avoid doing it twice
+ postponed_split_tab = 0;
+ return win_new_tabpage(n, NULL);
}
// Create up to "maxcount" tabpages with empty windows.
@@ -4494,11 +4496,12 @@ void goto_tabpage_tp(tabpage_T *tp, bool trigger_enter_autocmds, bool trigger_le
/// @return true if the tab page is valid, false otherwise.
bool goto_tabpage_lastused(void)
{
- if (valid_tabpage(lastused_tabpage)) {
- goto_tabpage_tp(lastused_tabpage, true, true);
- return true;
+ if (!valid_tabpage(lastused_tabpage)) {
+ return false;
}
- return false;
+
+ goto_tabpage_tp(lastused_tabpage, true, true);
+ return true;
}
// Enter window "wp" in tab page "tp".
@@ -7250,11 +7253,12 @@ static void clear_snapshot(tabpage_T *tp, int idx)
static void clear_snapshot_rec(frame_T *fr)
{
- if (fr != NULL) {
- clear_snapshot_rec(fr->fr_next);
- clear_snapshot_rec(fr->fr_child);
- xfree(fr);
+ if (fr == NULL) {
+ return;
}
+ clear_snapshot_rec(fr->fr_next);
+ clear_snapshot_rec(fr->fr_child);
+ xfree(fr);
}
/// Traverse a snapshot to find the previous curwin.