From 98b7b7324851aef0f8eedcd6a710552216dc41f1 Mon Sep 17 00:00:00 2001
From: Carles Fernandez <carles.fernandez@gmail.com>
Date: Sat, 11 Jun 2022 14:28:20 +0200
Subject: [PATCH] Replace list of if statements by switch

---
 src/algorithms/PVT/libs/rtklib_solver.cc | 64 ++++++++++--------------
 1 file changed, 27 insertions(+), 37 deletions(-)

diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc
index 142879e8c..aa07a83cc 100644
--- a/src/algorithms/PVT/libs/rtklib_solver.cc
+++ b/src/algorithms/PVT/libs/rtklib_solver.cc
@@ -73,69 +73,59 @@ Rtklib_Solver::Rtklib_Solver(const rtk_t &rtk,
     d_rtklib_band_index["L5"] = 2;
     d_rtklib_band_index["E6"] = 0;
 
-    if (d_type_of_rx == 6)  // E5b only
+    switch (d_type_of_rx)
         {
+        case 6:  // E5b only
             d_rtklib_freq_index[2] = 4;
-        }
-    if (d_type_of_rx == 11)  // GPS L1 C/A + Galileo E5b
-        {
+            break;
+        case 11:  // GPS L1 C/A + Galileo E5b
             d_rtklib_freq_index[2] = 4;
-        }
-    if (d_type_of_rx == 15)  // Galileo E1B + Galileo E5b
-        {
+            break;
+        case 15:  // Galileo E1B + Galileo E5b
             d_rtklib_freq_index[2] = 4;
-        }
-    if (d_type_of_rx == 18)  // GPS L2C + Galileo E5b
-        {
+            break;
+        case 18:  // GPS L2C + Galileo E5b
             d_rtklib_freq_index[2] = 4;
-        }
-    if (d_type_of_rx == 19)  // Galileo E5a + Galileo E5b
-        {
+            break;
+        case 19:  // Galileo E5a + Galileo E5b
             d_rtklib_band_index["5X"] = 0;
             d_rtklib_freq_index[0] = 2;
             d_rtklib_freq_index[2] = 4;
-        }
-    if (d_type_of_rx == 20)  // GPS L5 + Galileo E5b
-        {
+            break;
+        case 20:  // GPS L5 + Galileo E5b
             d_rtklib_band_index["L5"] = 0;
             d_rtklib_freq_index[0] = 2;
             d_rtklib_freq_index[2] = 4;
-        }
-    if (d_type_of_rx == 100)  // E6B only
-        {
+            break;
+        case 100:  // E6B only
             d_rtklib_freq_index[0] = 3;
-        }
-    if (d_type_of_rx == 101)  // E1 + E6B
-        {
+            break;
+        case 101:  // E1 + E6B
             d_rtklib_band_index["E6"] = 1;
             d_rtklib_freq_index[1] = 3;
-        }
-    if (d_type_of_rx == 102)  // E5a + E6B
-        {
+            break;
+        case 102:  // E5a + E6B
             d_rtklib_band_index["E6"] = 1;
             d_rtklib_freq_index[1] = 3;
-        }
-    if (d_type_of_rx == 103)  // E5b + E6B
-        {
+            break;
+        case 103:  // E5b + E6B
             d_rtklib_band_index["E6"] = 1;
             d_rtklib_freq_index[1] = 3;
             d_rtklib_freq_index[2] = 4;
-        }
-    if (d_type_of_rx == 104)  // Galileo E1B + Galileo E5a + Galileo E6B
-        {
+            break;
+        case 104:  // Galileo E1B + Galileo E5a + Galileo E6B
             d_rtklib_band_index["E6"] = 1;
             d_rtklib_freq_index[1] = 3;
-        }
-    if (d_type_of_rx == 105)  // Galileo E1B + Galileo E5b + Galileo E6B
-        {
+            break;
+        case 105:  // Galileo E1B + Galileo E5b + Galileo E6B
             d_rtklib_freq_index[2] = 4;
             d_rtklib_band_index["E6"] = 1;
             d_rtklib_freq_index[1] = 3;
-        }
-    if (d_type_of_rx == 106)  // GPS L1 C/A + Galileo E1B + Galileo E6B
-        {
+            break;
+        case 106:  // GPS L1 C/A + Galileo E1B + Galileo E6B
             d_rtklib_band_index["E6"] = 1;
             d_rtklib_freq_index[1] = 3;
+            break;
         }
 
     // ############# ENABLE DATA FILE LOG #################