diff src/profiler.c @ 31778:579c846086eb v9.0.1221

patch 9.0.1221: code is indented more than necessary Commit: https://github.com/vim/vim/commit/f97a295ccaa9803367f3714cdefce4e2283c771d Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Wed Jan 18 18:17:48 2023 +0000 patch 9.0.1221: 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 #11833)
author Bram Moolenaar <Bram@vim.org>
date Wed, 18 Jan 2023 19:30:03 +0100
parents 029c59bf78f1
children 04d9dff67d99
line wrap: on
line diff
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -910,16 +910,16 @@ script_prof_restore(proftime_T *tm)
 {
     scriptitem_T    *si;
 
-    if (SCRIPT_ID_VALID(current_sctx.sc_sid))
+    if (!SCRIPT_ID_VALID(current_sctx.sc_sid))
+	return;
+
+    si = SCRIPT_ITEM(current_sctx.sc_sid);
+    if (si->sn_prof_on && --si->sn_pr_nest == 0)
     {
-	si = SCRIPT_ITEM(current_sctx.sc_sid);
-	if (si->sn_prof_on && --si->sn_pr_nest == 0)
-	{
-	    profile_end(&si->sn_pr_child);
-	    profile_sub_wait(tm, &si->sn_pr_child); // don't count wait time
-	    profile_add(&si->sn_pr_children, &si->sn_pr_child);
-	    profile_add(&si->sn_prl_children, &si->sn_pr_child);
-	}
+	profile_end(&si->sn_pr_child);
+	profile_sub_wait(tm, &si->sn_pr_child); // don't count wait time
+	profile_add(&si->sn_pr_children, &si->sn_pr_child);
+	profile_add(&si->sn_prl_children, &si->sn_pr_child);
     }
 }
 
@@ -1009,17 +1009,17 @@ profile_dump(void)
 {
     FILE	*fd;
 
-    if (profile_fname != NULL)
+    if (profile_fname == NULL)
+	return;
+
+    fd = mch_fopen((char *)profile_fname, "w");
+    if (fd == NULL)
+	semsg(_(e_cant_open_file_str), profile_fname);
+    else
     {
-	fd = mch_fopen((char *)profile_fname, "w");
-	if (fd == NULL)
-	    semsg(_(e_cant_open_file_str), profile_fname);
-	else
-	{
-	    script_dump_profile(fd);
-	    func_dump_profile(fd);
-	    fclose(fd);
-	}
+	script_dump_profile(fd);
+	func_dump_profile(fd);
+	fclose(fd);
     }
 }