summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/AutoGen/GenDepex.py
diff options
context:
space:
mode:
authorCarsey, Jaben <jaben.carsey@intel.com>2018-04-28 06:32:53 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-05-04 13:07:56 +0800
commitcf3062901d6e8574c6322bb6236d8b004694b8f1 (patch)
tree3a178be9508664d6c08eaa56d1462c80ea128c17 /BaseTools/Source/Python/AutoGen/GenDepex.py
parentc5c7e68a915954d8fd15f6c8f3523c65ee06f489 (diff)
downloadedk2-cf3062901d6e8574c6322bb6236d8b004694b8f1.tar.gz
edk2-cf3062901d6e8574c6322bb6236d8b004694b8f1.tar.bz2
edk2-cf3062901d6e8574c6322bb6236d8b004694b8f1.zip
BaseTools: refactor Depex optomization
No need to make a list from the set. just pop the item off. 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>
Diffstat (limited to 'BaseTools/Source/Python/AutoGen/GenDepex.py')
-rw-r--r--BaseTools/Source/Python/AutoGen/GenDepex.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenDepex.py b/BaseTools/Source/Python/AutoGen/GenDepex.py
index 23b289500e..ed5df2b754 100644
--- a/BaseTools/Source/Python/AutoGen/GenDepex.py
+++ b/BaseTools/Source/Python/AutoGen/GenDepex.py
@@ -271,10 +271,14 @@ class DependencyExpression:
## Simply optimize the dependency expression by removing duplicated operands
def Optimize(self):
- ValidOpcode = list(set(self.OpcodeList))
- if len(ValidOpcode) != 1 or ValidOpcode[0] not in [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR]:
+ OpcodeSet = set(self.OpcodeList)
+ # if there are isn't one in the set, return
+ if len(OpcodeSet) != 1:
+ return
+ Op = OpcodeSet.pop()
+ #if Op isn't either OR or AND, return
+ if Op not in [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR]:
return
- Op = ValidOpcode[0]
NewOperand = []
AllOperand = set()
for Token in self.PostfixNotation: