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....@intel.com>
Cc: Yonghong Zhu <yonghong....@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.car...@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 36 ++++++++------------
 1 file changed, 15 insertions(+), 21 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py 
b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 3384fdb70b7e..b4575bcb8436 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -404,8 +404,8 @@ class WorkspaceAutoGen(AutoGen):
 
 
 
-            SourcePcdDict = {'DynamicEx':[], 
'PatchableInModule':[],'Dynamic':[],'FixedAtBuild':[]}
-            BinaryPcdDict = {'DynamicEx':[], 'PatchableInModule':[]}
+            SourcePcdDict = {'DynamicEx':set(), 
'PatchableInModule':set(),'Dynamic':set(),'FixedAtBuild':set()}
+            BinaryPcdDict = {'DynamicEx':set(), 'PatchableInModule':set()}
             SourcePcdDict_Keys = SourcePcdDict.keys()
             BinaryPcdDict_Keys = BinaryPcdDict.keys()
 
@@ -431,27 +431,21 @@ class WorkspaceAutoGen(AutoGen):
 
                         if 'DynamicEx' in BuildData.Pcds[key].Type:
                             if BuildData.IsBinaryModule:
-                                if (BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName) not in BinaryPcdDict['DynamicEx']:
-                                    
BinaryPcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+                                
BinaryPcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
                             else:
-                                if (BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['DynamicEx']:
-                                    
SourcePcdDict['DynamicEx'].append((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+                                
SourcePcdDict['DynamicEx'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
 
                         elif 'PatchableInModule' in BuildData.Pcds[key].Type:
                             if BuildData.MetaFile.Ext == '.inf':
                                 if BuildData.IsBinaryModule:
-                                    if (BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName) not in 
BinaryPcdDict['PatchableInModule']:
-                                        
BinaryPcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+                                    
BinaryPcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
                                 else:
-                                    if (BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName) not in 
SourcePcdDict['PatchableInModule']:
-                                        
SourcePcdDict['PatchableInModule'].append((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+                                    
SourcePcdDict['PatchableInModule'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
 
                         elif 'Dynamic' in BuildData.Pcds[key].Type:
-                            if (BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['Dynamic']:
-                                
SourcePcdDict['Dynamic'].append((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+                            
SourcePcdDict['Dynamic'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
                         elif 'FixedAtBuild' in BuildData.Pcds[key].Type:
-                            if (BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName) not in SourcePcdDict['FixedAtBuild']:
-                                
SourcePcdDict['FixedAtBuild'].append((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
+                            
SourcePcdDict['FixedAtBuild'].add((BuildData.Pcds[key].TokenCName, 
BuildData.Pcds[key].TokenSpaceGuidCName))
                 else:
                     pass
             #
@@ -460,13 +454,13 @@ class WorkspaceAutoGen(AutoGen):
             for i in SourcePcdDict_Keys:
                 for j in SourcePcdDict_Keys:
                     if i != j:
-                        IntersectionList = 
list(set(SourcePcdDict[i]).intersection(set(SourcePcdDict[j])))
-                        if len(IntersectionList) > 0:
+                        Intersections = 
SourcePcdDict[i].intersection(SourcePcdDict[j])
+                        if len(Intersections) > 0:
                             EdkLogger.error(
                             'build',
                             FORMAT_INVALID,
                             "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),
-                            ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) 
for P in IntersectionList])
+                            ExtraData="%s" % '\n\t'.join([str(P[1]+'.'+P[0]) 
for P in Intersections])
                             )
                     else:
                         pass
@@ -477,8 +471,8 @@ class WorkspaceAutoGen(AutoGen):
             for i in BinaryPcdDict_Keys:
                 for j in BinaryPcdDict_Keys:
                     if i != j:
-                        IntersectionList = 
list(set(BinaryPcdDict[i]).intersection(set(BinaryPcdDict[j])))
-                        for item in IntersectionList:
+                        Intersections = 
BinaryPcdDict[i].intersection(BinaryPcdDict[j])
+                        for item in Intersections:
                             NewPcd1 = (item[0] + '_' + i, item[1])
                             NewPcd2 = (item[0] + '_' + j, item[1])
                             if item not in GlobalData.MixedPcd:
@@ -497,8 +491,8 @@ class WorkspaceAutoGen(AutoGen):
             for i in SourcePcdDict_Keys:
                 for j in BinaryPcdDict_Keys:
                     if i != j:
-                        IntersectionList = 
list(set(SourcePcdDict[i]).intersection(set(BinaryPcdDict[j])))
-                        for item in IntersectionList:
+                        Intersections = 
SourcePcdDict[i].intersection(BinaryPcdDict[j])
+                        for item in Intersections:
                             NewPcd1 = (item[0] + '_' + i, item[1])
                             NewPcd2 = (item[0] + '_' + j, item[1])
                             if item not in GlobalData.MixedPcd:
-- 
2.16.2.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to