comparison src/vim9type.c @ 31827:1009c33499e7 v9.0.1246

patch 9.0.1246: code is indented more than necessary Commit: https://github.com/vim/vim/commit/142ed77898facf8f423fee2717efee1749c55f9a Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Thu Jan 26 12:00:00 2023 +0000 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)
author Bram Moolenaar <Bram@vim.org>
date Thu, 26 Jan 2023 13:15:04 +0100
parents 6377d791dcd1
children 16025ef158bf
comparison
equal deleted inserted replaced
31826:06619adfbcdd 31827:1009c33499e7
35 type_T *type; 35 type_T *type;
36 36
37 if (ga_grow(type_gap, 1) == FAIL) 37 if (ga_grow(type_gap, 1) == FAIL)
38 return NULL; 38 return NULL;
39 type = ALLOC_CLEAR_ONE(type_T); 39 type = ALLOC_CLEAR_ONE(type_T);
40 if (type != NULL) 40 if (type == NULL)
41 { 41 return NULL;
42 ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type; 42
43 ++type_gap->ga_len; 43 ((type_T **)type_gap->ga_data)[type_gap->ga_len] = type;
44 } 44 ++type_gap->ga_len;
45 return type; 45 return type;
46 } 46 }
47 47
48 /* 48 /*
49 * Make a shallow copy of "type". 49 * Make a shallow copy of "type".
626 type_T * 626 type_T *
627 typval2type(typval_T *tv, int copyID, garray_T *type_gap, int flags) 627 typval2type(typval_T *tv, int copyID, garray_T *type_gap, int flags)
628 { 628 {
629 type_T *type = typval2type_int(tv, copyID, type_gap, flags); 629 type_T *type = typval2type_int(tv, copyID, type_gap, flags);
630 630
631 if (type != NULL) 631 if (type == NULL)
632 { 632 return NULL;
633 if (type != &t_bool && (tv->v_type == VAR_NUMBER 633
634 && (tv->vval.v_number == 0 || tv->vval.v_number == 1))) 634 if (type != &t_bool && (tv->v_type == VAR_NUMBER
635 // Number 0 and 1 and expression with "&&" or "||" can also be used 635 && (tv->vval.v_number == 0 || tv->vval.v_number == 1)))
636 // for bool. 636 // Number 0 and 1 and expression with "&&" or "||" can also be used
637 type = &t_number_bool; 637 // for bool.
638 else if (type != &t_float && tv->v_type == VAR_NUMBER) 638 type = &t_number_bool;
639 // A number can also be used for float. 639 else if (type != &t_float && tv->v_type == VAR_NUMBER)
640 type = &t_number_float; 640 // A number can also be used for float.
641 } 641 type = &t_number_float;
642 return type; 642 return type;
643 } 643 }
644 644
645 /* 645 /*
646 * Return TRUE if "type" can be used for a variable declaration. 646 * Return TRUE if "type" can be used for a variable declaration.