← Back to team overview

kicad-developers team mailing list archive

[Patch] Clean up switch statement in pcbnew launcher

 

The switch statement for choosing which frame to launch in Pcbnew had an
extra nested switch inside of it. It appears that the original performance
enhancement reason for doing that has been modified, so now there was no
benefit to having the nested switches. This patch removes the nesting.

-Ian
From 66f8772bbbbe179559c08f4d9ff2df72a8b3784b Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Wed, 14 Aug 2019 01:28:11 +0200
Subject: [PATCH] pcbnew: Clean up switch statement in launcher

---
 pcbnew/pcbnew.cpp | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp
index aa1a40aed..b2ebb4437 100644
--- a/pcbnew/pcbnew.cpp
+++ b/pcbnew/pcbnew.cpp
@@ -99,18 +99,12 @@ static struct IFACE : public KIFACE_I
         }
 
         case FRAME_PCB_MODULE_EDITOR:
+            return new FOOTPRINT_EDIT_FRAME( aKiway, aParent,
+                                             EDA_DRAW_PANEL_GAL::GAL_TYPE_UNKNOWN );
+
         case FRAME_PCB_MODULE_VIEWER:
         case FRAME_PCB_MODULE_VIEWER_MODAL:
-        {
-            switch( aClassId )
-            {
-            case FRAME_PCB_MODULE_EDITOR:
-                return new FOOTPRINT_EDIT_FRAME( aKiway, aParent, EDA_DRAW_PANEL_GAL::GAL_TYPE_UNKNOWN );
-            case FRAME_PCB_MODULE_VIEWER:
-            case FRAME_PCB_MODULE_VIEWER_MODAL:
-                return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
-            }
-        }
+            return new FOOTPRINT_VIEWER_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
 
         case FRAME_PCB_FOOTPRINT_WIZARD:
             return new FOOTPRINT_WIZARD_FRAME( aKiway, aParent, FRAME_T( aClassId ) );
-- 
2.21.0


Follow ups