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)
diff --git a/src/profiler.c b/src/profiler.c
index 03348df..b971cd7 100644
--- a/src/profiler.c
+++ b/src/profiler.c
@@ -910,16 +910,16 @@
{
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 @@
{
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);
}
}