the function doesn't use self and can be static
defaultdict replaces dict and removes the dict initialization code

Cc: Liming Gao <[email protected]>
Cc: Yonghong Zhu <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <[email protected]>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py 
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index be3f7b6881e8..904c52d9576a 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -39,7 +39,7 @@ import Common.GlobalData as GlobalData
 import subprocess
 from Common.Misc import SaveFileOnChange
 from Workspace.BuildClassObject import PlatformBuildClassObject, StructurePcd, 
PcdClassObject, ModuleBuildClassObject
-from collections import OrderedDict
+from collections import OrderedDict,defaultdict
 
 variablePattern = re.compile(r'[\t\s]*0[xX][a-fA-F0-9]+$')
 
@@ -1187,11 +1187,10 @@ class DscBuildData(PlatformBuildClassObject):
                             options[Key] += ' ' + Option
         return self._ModuleTypeOptions[Edk, ModuleType]
 
-    def GetStructurePcdInfo(self, PcdSet):
-        structure_pcd_data = {}
+    @staticmethod
+    def GetStructurePcdInfo(PcdSet):
+        structure_pcd_data = defaultdict(list)
         for item in PcdSet:
-            if (item[0],item[1]) not in structure_pcd_data:
-                structure_pcd_data[(item[0],item[1])] = []
             structure_pcd_data[(item[0],item[1])].append(item)
 
         return structure_pcd_data
@@ -1298,7 +1297,7 @@ class DscBuildData(PlatformBuildClassObject):
                 S_PcdSet.append([ 
TokenSpaceGuid.split(".")[0],TokenSpaceGuid.split(".")[1], PcdCName,SkuName, 
default_store,Dummy5, AnalyzePcdExpression(Setting)[0]])
 
         # handle pcd value override
-        StrPcdSet = self.GetStructurePcdInfo(S_PcdSet)
+        StrPcdSet = DscBuildData.GetStructurePcdInfo(S_PcdSet)
         S_pcd_set = OrderedDict()
         for str_pcd in StrPcdSet:
             str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None)
-- 
2.16.2.windows.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to