]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: refactor to use list not dict
authorCarsey, Jaben <jaben.carsey@intel.com>
Fri, 27 Apr 2018 22:32:28 +0000 (06:32 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 4 May 2018 05:03:03 +0000 (13:03 +0800)
since we never access the values in the copied dict, just use a list instead.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
BaseTools/Source/Python/Common/ToolDefClassObject.py
BaseTools/Source/Python/GenFds/GenFds.py

index 73ebdaf6b1793646fffcfc3fe06e1835c510fe99..83359586b99444c8c72744808ee1638e51325dfc 100644 (file)
@@ -92,7 +92,9 @@ class ToolDefClassObject(object):
 \r
         KeyList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE]\r
         for Index in range(3, -1, -1):\r
-            for Key in dict(self.ToolsDefTxtDictionary):\r
+            # make a copy of the keys to enumerate over to prevent issues when\r
+            # adding/removing items from the original dict.\r
+            for Key in list(self.ToolsDefTxtDictionary.keys()):\r
                 List = Key.split('_')\r
                 if List[Index] == '*':\r
                     for String in self.ToolsDefTxtDatabase[KeyList[Index]]:\r
@@ -100,7 +102,6 @@ class ToolDefClassObject(object):
                         NewKey = '%s_%s_%s_%s_%s' % tuple(List)\r
                         if NewKey not in self.ToolsDefTxtDictionary:\r
                             self.ToolsDefTxtDictionary[NewKey] = self.ToolsDefTxtDictionary[Key]\r
-                        continue\r
                     del self.ToolsDefTxtDictionary[Key]\r
                 elif List[Index] not in self.ToolsDefTxtDatabase[KeyList[Index]]:\r
                     del self.ToolsDefTxtDictionary[Key]\r
index ccd137955dd8fd18dcb56ed4b2024519de5b2e53..e17affc0960e475af037e1d364dfc59176332c5e 100644 (file)
@@ -428,7 +428,7 @@ def FindExtendTool(KeyStringList, CurrentArchList, NameGuid):
         if BuildOption:\r
             ToolList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH]\r
             for Index in range(2, -1, -1):\r
-                for Key in dict(BuildOption):\r
+                for Key in list(BuildOption.keys()):\r
                     List = Key.split('_')\r
                     if List[Index] == '*':\r
                         for String in ToolDb[ToolList[Index]]:\r