[CodeClean] combine if statements
authorJunsang Mo <junsang.mo@samsung.com>
Thu, 17 Oct 2019 12:46:27 +0000 (21:46 +0900)
committerwooksong <wook16.song@samsung.com>
Sat, 19 Oct 2019 13:48:00 +0000 (22:48 +0900)
combine if statements in tensor_transform.c.
I confirmed it worked well in example_image_classification_tflite.

Signed-off-by: Junsang Mo <junsang.mo@samsung.com>
gst/nnstreamer/tensor_transform/tensor_transform.c

index 030abb1..14f2805 100644 (file)
@@ -1478,27 +1478,16 @@ gst_tensor_transform_convert_dimension (GstTensorTransform * filter,
         int b = filter->data_dimchg.to;
 
         for (i = 0; i < NNS_TENSOR_RANK_LIMIT; i++) {
-          if (i < a && i < b) {
-            out_info->dimension[i] = in_info->dimension[i];
-          } else if (i > a && i > b) {
+          if ((i < a && i < b) || (i > a && i > b) || a == b) {
             out_info->dimension[i] = in_info->dimension[i];
+          } else if (i == b) {
+            out_info->dimension[i] = in_info->dimension[a];
           } else if (a > b) {
-            if (i == b) {
-              out_info->dimension[i] = in_info->dimension[a];
-            } else {
-              g_assert (i > 0 && i > b);
-              out_info->dimension[i] = in_info->dimension[i - 1];
-            }
-          } else if (a < b) {
-            if (i == b) {
-              out_info->dimension[i] = in_info->dimension[a];
-            } else {
-              g_assert (i < b && i < (NNS_TENSOR_RANK_LIMIT - 1));
-              out_info->dimension[i] = in_info->dimension[i + 1];
-            }
+            g_assert (i > 0 && i > b);
+            out_info->dimension[i] = in_info->dimension[i - 1];
           } else {
-            /* a == b */
-            out_info->dimension[i] = in_info->dimension[i];
+            g_assert (i < b && i < (NNS_TENSOR_RANK_LIMIT - 1));
+            out_info->dimension[i] = in_info->dimension[i + 1];
           }
         }
       } else {
@@ -1506,27 +1495,16 @@ gst_tensor_transform_convert_dimension (GstTensorTransform * filter,
         int b = filter->data_dimchg.to;
 
         for (i = 0; i < NNS_TENSOR_RANK_LIMIT; i++) {
-          if (i < a && i < b) {
-            out_info->dimension[i] = in_info->dimension[i];
-          } else if (i > a && i > b) {
+          if ((i < a && i < b) || (i > a && i > b) || a == b) {
             out_info->dimension[i] = in_info->dimension[i];
+          } else if (i == a) {
+            out_info->dimension[i] = in_info->dimension[b];
           } else if (a > b) {
-            if (i == a) {
-              out_info->dimension[i] = in_info->dimension[b];
-            } else {
-              g_assert (i < a && i < (NNS_TENSOR_RANK_LIMIT - 1));
-              out_info->dimension[i] = in_info->dimension[i + 1];
-            }
-          } else if (a < b) {
-            if (i == a) {
-              out_info->dimension[i] = in_info->dimension[b];
-            } else {
-              g_assert (i > 0 && i > a);
-              out_info->dimension[i] = in_info->dimension[i - 1];
-            }
+            g_assert (i < a && i < (NNS_TENSOR_RANK_LIMIT - 1));
+            out_info->dimension[i] = in_info->dimension[i + 1];
           } else {
-            /* a == b */
-            out_info->dimension[i] = in_info->dimension[i];
+            g_assert (i > 0 && i > a);
+            out_info->dimension[i] = in_info->dimension[i - 1];
           }
         }
       }