]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: refactor Depex optomization
authorCarsey, Jaben <jaben.carsey@intel.com>
Fri, 27 Apr 2018 22:32:53 +0000 (06:32 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 4 May 2018 05:07:56 +0000 (13:07 +0800)
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>
BaseTools/Source/Python/AutoGen/GenDepex.py

index 23b289500e014a8f6f395c6bb1c28930390a8c6b..ed5df2b75440172ac6253a6e5aa18fccbeeb025d 100644 (file)
@@ -271,10 +271,14 @@ class DependencyExpression:
 \r
     ## Simply optimize the dependency expression by removing duplicated operands\r
     def Optimize(self):\r
-        ValidOpcode = list(set(self.OpcodeList))\r
-        if len(ValidOpcode) != 1 or ValidOpcode[0] not in [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR]:\r
+        OpcodeSet = set(self.OpcodeList)\r
+        # if there are isn't one in the set, return\r
+        if len(OpcodeSet) != 1:\r
+          return\r
+        Op = OpcodeSet.pop()\r
+        #if Op isn't either OR or AND, return\r
+        if Op not in [DEPEX_OPCODE_AND, DEPEX_OPCODE_OR]:\r
             return\r
-        Op = ValidOpcode[0]\r
         NewOperand = []\r
         AllOperand = set()\r
         for Token in self.PostfixNotation:\r