diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-01-26 12:00:00 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2023-01-26 12:00:00 +0000 |
commit | 142ed77898facf8f423fee2717efee1749c55f9a (patch) | |
tree | 9b8f51cd7992358ae3a01c9cd152eed223d1827e /src/vim9script.c | |
parent | 032713f8299abd92fcfb1e490d1ae5c1ecadde41 (diff) | |
download | vim-git-142ed77898facf8f423fee2717efee1749c55f9a.tar.gz |
patch 9.0.1246: code is indented more than necessaryv9.0.1246
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes #11887)
Diffstat (limited to 'src/vim9script.c')
-rw-r--r-- | src/vim9script.c | 67 |
1 files changed, 34 insertions, 33 deletions
diff --git a/src/vim9script.c b/src/vim9script.c index 0af7bb6d0..fd4658c6f 100644 --- a/src/vim9script.c +++ b/src/vim9script.c @@ -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)) + + 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) { - dictitem_T *di = HI2DI(script_hi); - sallvar_T *sav = HI2SAV(all_hi); - sallvar_T *sav_prev = NULL; + sav_prev = sav; + sav = sav->sav_next; + } + if (sav == NULL) + return; - // 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 (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); } /* |