diff 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
line wrap: on
line diff
--- 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, ga
 {
     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;
 }