refactor: reduce scope of locals as per the style guide (#22206)

This commit is contained in:
dundargoc
2023-02-11 10:24:46 +01:00
committed by GitHub
parent c9b0fe1f41
commit c8c930ea78
21 changed files with 240 additions and 397 deletions

View File

@@ -689,10 +689,8 @@ void profile_init(scriptitem_T *si)
/// @param tm place to store wait time
void script_prof_save(proftime_T *tm)
{
scriptitem_T *si;
if (current_sctx.sc_sid > 0 && current_sctx.sc_sid <= script_items.ga_len) {
si = &SCRIPT_ITEM(current_sctx.sc_sid);
scriptitem_T *si = &SCRIPT_ITEM(current_sctx.sc_sid);
if (si->sn_prof_on && si->sn_pr_nest++ == 0) {
si->sn_pr_child = profile_start();
}
@@ -720,12 +718,11 @@ void script_prof_restore(const proftime_T *tm)
/// Dump the profiling results for all scripts in file "fd".
static void script_dump_profile(FILE *fd)
{
scriptitem_T *si;
FILE *sfd;
sn_prl_T *pp;
for (int id = 1; id <= script_items.ga_len; id++) {
si = &SCRIPT_ITEM(id);
scriptitem_T *si = &SCRIPT_ITEM(id);
if (si->sn_prof_on) {
fprintf(fd, "SCRIPT %s\n", si->sn_name);
if (si->sn_pr_count == 1) {
@@ -808,7 +805,6 @@ void profile_dump(void)
void script_line_start(void)
{
scriptitem_T *si;
sn_prl_T *pp;
if (current_sctx.sc_sid <= 0 || current_sctx.sc_sid > script_items.ga_len) {
return;
@@ -822,7 +818,7 @@ void script_line_start(void)
while (si->sn_prl_ga.ga_len <= si->sn_prl_idx
&& si->sn_prl_ga.ga_len < si->sn_prl_ga.ga_maxlen) {
// Zero counters for a line that was not used before.
pp = &PRL_ITEM(si, si->sn_prl_ga.ga_len);
sn_prl_T *pp = &PRL_ITEM(si, si->sn_prl_ga.ga_len);
pp->snp_count = 0;
pp->sn_prl_total = profile_zero();
pp->sn_prl_self = profile_zero();
@@ -853,7 +849,6 @@ void script_line_exec(void)
void script_line_end(void)
{
scriptitem_T *si;
sn_prl_T *pp;
if (current_sctx.sc_sid <= 0 || current_sctx.sc_sid > script_items.ga_len) {
return;
@@ -862,7 +857,7 @@ void script_line_end(void)
if (si->sn_prof_on && si->sn_prl_idx >= 0
&& si->sn_prl_idx < si->sn_prl_ga.ga_len) {
if (si->sn_prl_execed) {
pp = &PRL_ITEM(si, si->sn_prl_idx);
sn_prl_T *pp = &PRL_ITEM(si, si->sn_prl_idx);
pp->snp_count++;
si->sn_prl_start = profile_end(si->sn_prl_start);
si->sn_prl_start = profile_sub_wait(si->sn_prl_wait, si->sn_prl_start);