diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-02-03 10:22:11 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-03 10:22:11 +0800 |
commit | 9ab9cde2ca7b917a894068698ef2fec3a851fdd5 (patch) | |
tree | 8ed12c4c073cfb8ff25e062cbbbdc63a9feecd84 /src/nvim/eval/typval.c | |
parent | 1f40b4e22232f22551a9ae89a9f8d59b5ba0c0b6 (diff) | |
download | rneovim-9ab9cde2ca7b917a894068698ef2fec3a851fdd5.tar.gz rneovim-9ab9cde2ca7b917a894068698ef2fec3a851fdd5.tar.bz2 rneovim-9ab9cde2ca7b917a894068698ef2fec3a851fdd5.zip |
vim-patch:partial:9.0.1196: code is indented more than necessary (#27315)
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes vim/vim#11813)
https://github.com/vim/vim/commit/e8575988969579f9e1439181ae338b2ff74054a8
Skip list_alloc_with_items().
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/eval/typval.c')
-rw-r--r-- | src/nvim/eval/typval.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index d510cf2a3d..fb9e7ff9a8 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -623,13 +623,14 @@ tv_list_copy_error: listitem_T *tv_list_check_range_index_one(list_T *const l, int *const n1, const bool quiet) { listitem_T *li = tv_list_find_index(l, n1); - if (li == NULL) { - if (!quiet) { - semsg(_(e_list_index_out_of_range_nr), (int64_t)(*n1)); - } - return NULL; + if (li != NULL) { + return li; } - return li; + + if (!quiet) { + semsg(_(e_list_index_out_of_range_nr), (int64_t)(*n1)); + } + return NULL; } /// Check that "n2" can be used as the second index in a range of list "l". @@ -1634,11 +1635,13 @@ static listitem_T *tv_list_find_index(list_T *const l, int *const idx) FUNC_ATTR_WARN_UNUSED_RESULT { listitem_T *li = tv_list_find(l, *idx); - if (li == NULL) { - if (*idx < 0) { - *idx = 0; - li = tv_list_find(l, *idx); - } + if (li != NULL) { + return li; + } + + if (*idx < 0) { + *idx = 0; + li = tv_list_find(l, *idx); } return li; } @@ -2130,10 +2133,12 @@ void tv_dict_free_dict(dict_T *const d) void tv_dict_free(dict_T *const d) FUNC_ATTR_NONNULL_ALL { - if (!tv_in_free_unref_items) { - tv_dict_free_contents(d); - tv_dict_free_dict(d); + if (tv_in_free_unref_items) { + return; } + + tv_dict_free_contents(d); + tv_dict_free_dict(d); } /// Unreference a dictionary |