]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Autogen - change from list to set
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Wed, 4 Apr 2018 20:56:56 +0000 (04:56 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Sun, 8 Apr 2018 08:33:03 +0000 (16:33 +0800)
by changing from list to set(), we can skip all the preprocessing
to prevent duplication and we dont need to convert to a set() later
on for each use

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/AutoGen/AutoGen.py

index 4088fb9c8b7d641846e47600f603b0dcff6fa86f..ef2e3ebe853c1e129536f01e2e2dc4c694189c47 100644 (file)
@@ -415,8 +415,8 @@ class WorkspaceAutoGen(AutoGen):
 \r
 \r
 \r
-            SourcePcdDict = {'DynamicEx':[], 'PatchableInModule':[],'Dynamic':[],'FixedAtBuild':[]}\r
-            BinaryPcdDict = {'DynamicEx':[], 'PatchableInModule':[]}\r
+            SourcePcdDict = {'DynamicEx':set(), 'PatchableInModule':set(),'Dynamic':set(),'FixedAtBuild':set()}\r
+            BinaryPcdDict = {'DynamicEx':set(), 'PatchableInModule':set()}\r
             SourcePcdDict_Keys = SourcePcdDict.keys()\r
             BinaryPcdDict_Keys = BinaryPcdDict.keys()\r
 \r
@@ -442,27 +442,21 @@ class WorkspaceAutoGen(AutoGen):
 \r
                         if 'DynamicEx' in BuildData.Pcds[key].Type:\r
                             if BuildData.IsBinaryModule:\r
-                                if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in BinaryPcdDict['DynamicEx']:\r
-                                    BinaryPcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+                                BinaryPcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
                             else:\r
-                                if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['DynamicEx']:\r
-                                    SourcePcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+                                SourcePcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
 \r
                         elif 'PatchableInModule' in BuildData.Pcds[key].Type:\r
                             if BuildData.MetaFile.Ext == '.inf':\r
                                 if BuildData.IsBinaryModule:\r
-                                    if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in BinaryPcdDict['PatchableInModule']:\r
-                                        BinaryPcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+                                    BinaryPcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
                                 else:\r
-                                    if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['PatchableInModule']:\r
-                                        SourcePcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+                                    SourcePcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
 \r
                         elif 'Dynamic' in BuildData.Pcds[key].Type:\r
-                            if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['Dynamic']:\r
-                                SourcePcdDict['Dynamic'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+                            SourcePcdDict['Dynamic'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
                         elif 'FixedAtBuild' in BuildData.Pcds[key].Type:\r
-                            if (BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['FixedAtBuild']:\r
-                                SourcePcdDict['FixedAtBuild'].append((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
+                            SourcePcdDict['FixedAtBuild'].add((BuildData.Pcds[key].TokenCName, BuildData.Pcds[key].TokenSpaceGuidCName))\r
                 else:\r
                     pass\r
             #\r
@@ -471,13 +465,13 @@ class WorkspaceAutoGen(AutoGen):
             for i in SourcePcdDict_Keys:\r
                 for j in SourcePcdDict_Keys:\r
                     if i != j:\r
-                        IntersectionList = list(set(SourcePcdDict[i]).intersection(set(SourcePcdDict[j])))\r
-                        if len(IntersectionList) > 0:\r
+                        Intersections = SourcePcdDict[i].intersection(SourcePcdDict[j])\r
+                        if len(Intersections) > 0:\r
                             EdkLogger.error(\r
                             'build',\r
                             FORMAT_INVALID,\r
                             "Building modules from source INFs, following PCD use %s and %s access method. It must be corrected to use only one access method." % (i, j),\r
-                            ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) for P in IntersectionList])\r
+                            ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) for P in Intersections])\r
                             )\r
                     else:\r
                         pass\r
@@ -488,8 +482,8 @@ class WorkspaceAutoGen(AutoGen):
             for i in BinaryPcdDict_Keys:\r
                 for j in BinaryPcdDict_Keys:\r
                     if i != j:\r
-                        IntersectionList = list(set(BinaryPcdDict[i]).intersection(set(BinaryPcdDict[j])))\r
-                        for item in IntersectionList:\r
+                        Intersections = BinaryPcdDict[i].intersection(BinaryPcdDict[j])\r
+                        for item in Intersections:\r
                             NewPcd1 = (item[0] + '_' + i, item[1])\r
                             NewPcd2 = (item[0] + '_' + j, item[1])\r
                             if item not in GlobalData.MixedPcd:\r
@@ -508,8 +502,8 @@ class WorkspaceAutoGen(AutoGen):
             for i in SourcePcdDict_Keys:\r
                 for j in BinaryPcdDict_Keys:\r
                     if i != j:\r
-                        IntersectionList = list(set(SourcePcdDict[i]).intersection(set(BinaryPcdDict[j])))\r
-                        for item in IntersectionList:\r
+                        Intersections = SourcePcdDict[i].intersection(BinaryPcdDict[j])\r
+                        for item in Intersections:\r
                             NewPcd1 = (item[0] + '_' + i, item[1])\r
                             NewPcd2 = (item[0] + '_' + j, item[1])\r
                             if item not in GlobalData.MixedPcd:\r