0
0
mirror of https://github.com/vim/vim.git synced 2025-09-24 03:44:06 -04:00

patch 9.0.1246: 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 #11887)
This commit is contained in:
Yegappan Lakshmanan
2023-01-26 12:00:00 +00:00
committed by Bram Moolenaar
parent 032713f829
commit 142ed77898
13 changed files with 510 additions and 515 deletions

View File

@@ -1007,42 +1007,43 @@ hide_script_var(scriptitem_T *si, int idx, int func_defined)
// The typval is moved into the sallvar_T.
script_hi = hash_find(script_ht, sv->sv_name);
all_hi = hash_find(all_ht, sv->sv_name);
if (!HASHITEM_EMPTY(script_hi) && !HASHITEM_EMPTY(all_hi))
{
dictitem_T *di = HI2DI(script_hi);
sallvar_T *sav = HI2SAV(all_hi);
sallvar_T *sav_prev = NULL;
// There can be multiple entries with the same name in different
// blocks, find the right one.
while (sav != NULL && sav->sav_var_vals_idx != idx)
{
sav_prev = sav;
sav = sav->sav_next;
}
if (sav != NULL)
{
if (func_defined)
{
// move the typval from the dictitem to the sallvar
sav->sav_tv = di->di_tv;
di->di_tv.v_type = VAR_UNKNOWN;
sav->sav_flags = di->di_flags;
sav->sav_di = NULL;
sv->sv_tv = &sav->sav_tv;
}
else
{
if (sav_prev == NULL)
hash_remove(all_ht, all_hi, "hide variable");
else
sav_prev->sav_next = sav->sav_next;
sv->sv_name = NULL;
vim_free(sav);
}
delete_var(script_ht, script_hi);
}
if (HASHITEM_EMPTY(script_hi) || HASHITEM_EMPTY(all_hi))
return;
dictitem_T *di = HI2DI(script_hi);
sallvar_T *sav = HI2SAV(all_hi);
sallvar_T *sav_prev = NULL;
// There can be multiple entries with the same name in different
// blocks, find the right one.
while (sav != NULL && sav->sav_var_vals_idx != idx)
{
sav_prev = sav;
sav = sav->sav_next;
}
if (sav == NULL)
return;
if (func_defined)
{
// move the typval from the dictitem to the sallvar
sav->sav_tv = di->di_tv;
di->di_tv.v_type = VAR_UNKNOWN;
sav->sav_flags = di->di_flags;
sav->sav_di = NULL;
sv->sv_tv = &sav->sav_tv;
}
else
{
if (sav_prev == NULL)
hash_remove(all_ht, all_hi, "hide variable");
else
sav_prev->sav_next = sav->sav_next;
sv->sv_name = NULL;
vim_free(sav);
}
delete_var(script_ht, script_hi);
}
/*