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/vim9type.c | |
parent | 032713f8299abd92fcfb1e490d1ae5c1ecadde41 (diff) |
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/vim9type.c')
-rw-r--r-- | src/vim9type.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/vim9type.c b/src/vim9type.c index 61853956e8..075eb60d54 100644 --- a/src/vim9type.c +++ b/src/vim9type.c @@ -37,11 +37,11 @@ get_type_ptr(garray_T *type_gap) if (ga_grow(type_gap, 1) == FAIL) return NULL; type = ALLOC_CLEAR_ONE(type_T); - if (type != NULL) - { - ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type; - ++type_gap->ga_len; - } + if (type == NULL) + return NULL; + + ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type; + ++type_gap->ga_len; return type; } @@ -628,17 +628,17 @@ typval2type(typval_T *tv, int copyID, garray_T *type_gap, int flags) { type_T *type = typval2type_int(tv, copyID, type_gap, flags); - if (type != NULL) - { - if (type != &t_bool && (tv->v_type == VAR_NUMBER - && (tv->vval.v_number == 0 || tv->vval.v_number == 1))) - // Number 0 and 1 and expression with "&&" or "||" can also be used - // for bool. - type = &t_number_bool; - else if (type != &t_float && tv->v_type == VAR_NUMBER) - // A number can also be used for float. - type = &t_number_float; - } + if (type == NULL) + return NULL; + + if (type != &t_bool && (tv->v_type == VAR_NUMBER + && (tv->vval.v_number == 0 || tv->vval.v_number == 1))) + // Number 0 and 1 and expression with "&&" or "||" can also be used + // for bool. + type = &t_number_bool; + else if (type != &t_float && tv->v_type == VAR_NUMBER) + // A number can also be used for float. + type = &t_number_float; return type; } |