diff src/session.c @ 31809:543153d582d5 v9.0.1237

patch 9.0.1237: code is indented more than necessary Commit: https://github.com/vim/vim/commit/6ec66660476562e643deceb7c325cd0e8c903663 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Mon Jan 23 20:46:21 2023 +0000 patch 9.0.1237: code is indented more than necessary Problem: Code is indented more than necessary. Solution: Use an early return where it makes sense. (Yegappan Lakshmanan, closes #11858)
author Bram Moolenaar <Bram@vim.org>
date Mon, 23 Jan 2023 22:00:04 +0100
parents 029c59bf78f1
children 04d9dff67d99
line wrap: on
line diff
--- a/src/session.c
+++ b/src/session.c
@@ -200,41 +200,42 @@ ses_win_rec(FILE *fd, frame_T *fr)
     frame_T	*frc;
     int		count = 0;
 
-    if (fr->fr_layout != FR_LEAF)
-    {
-	// Find first frame that's not skipped and then create a window for
-	// each following one (first frame is already there).
-	frc = ses_skipframe(fr->fr_child);
-	if (frc != NULL)
-	    while ((frc = ses_skipframe(frc->fr_next)) != NULL)
-	    {
-		// Make window as big as possible so that we have lots of room
-		// to split.
-		if (put_line(fd, "wincmd _ | wincmd |") == FAIL
-			|| put_line(fd, fr->fr_layout == FR_COL
-						? "split" : "vsplit") == FAIL)
-		    return FAIL;
-		++count;
-	    }
+    if (fr->fr_layout == FR_LEAF)
+	return OK;
+
+    // Find first frame that's not skipped and then create a window for
+    // each following one (first frame is already there).
+    frc = ses_skipframe(fr->fr_child);
+    if (frc != NULL)
+	while ((frc = ses_skipframe(frc->fr_next)) != NULL)
+	{
+	    // Make window as big as possible so that we have lots of room
+	    // to split.
+	    if (put_line(fd, "wincmd _ | wincmd |") == FAIL
+		    || put_line(fd, fr->fr_layout == FR_COL
+			? "split" : "vsplit") == FAIL)
+		return FAIL;
+	    ++count;
+	}
 
-	// Go back to the first window.
-	if (count > 0 && (fprintf(fd, fr->fr_layout == FR_COL
-			? "%dwincmd k" : "%dwincmd h", count) < 0
-						      || put_eol(fd) == FAIL))
-	    return FAIL;
+    // Go back to the first window.
+    if (count > 0 && (fprintf(fd, fr->fr_layout == FR_COL
+		    ? "%dwincmd k" : "%dwincmd h", count) < 0
+		|| put_eol(fd) == FAIL))
+	return FAIL;
 
-	// Recursively create frames/windows in each window of this column or
-	// row.
-	frc = ses_skipframe(fr->fr_child);
-	while (frc != NULL)
-	{
-	    ses_win_rec(fd, frc);
-	    frc = ses_skipframe(frc->fr_next);
-	    // Go to next window.
-	    if (frc != NULL && put_line(fd, "wincmd w") == FAIL)
-		return FAIL;
-	}
+    // Recursively create frames/windows in each window of this column or
+    // row.
+    frc = ses_skipframe(fr->fr_child);
+    while (frc != NULL)
+    {
+	ses_win_rec(fd, frc);
+	frc = ses_skipframe(frc->fr_next);
+	// Go to next window.
+	if (frc != NULL && put_line(fd, "wincmd w") == FAIL)
+	    return FAIL;
     }
+
     return OK;
 }
 
@@ -1068,11 +1069,11 @@ ex_loadview(exarg_T *eap)
     char_u	*fname;
 
     fname = get_view_file(*eap->arg);
-    if (fname != NULL)
-    {
-	do_source(fname, FALSE, DOSO_NONE, NULL);
-	vim_free(fname);
-    }
+    if (fname == NULL)
+	return;
+
+    do_source(fname, FALSE, DOSO_NONE, NULL);
+    vim_free(fname);
 }
 
 # if defined(FEAT_GUI_GNOME) \