BaseTools: Expression - change from series of if to elif
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Tue, 13 Mar 2018 23:11:33 +0000 (07:11 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Mon, 19 Mar 2018 01:25:33 +0000 (09:25 +0800)
since the first character of the string cannot be found by multiple if
statements, use elif to optomize the behavior.

Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@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/Common/Expression.py

index c7037dd..85c1ce9 100644 (file)
@@ -93,18 +93,18 @@ def SplitPcdValueString(String):
     for i, ch in enumerate(String):\r
         if ch == '(':\r
             InParenthesis += 1\r
-        if ch == ')':\r
+        elif ch == ')':\r
             if InParenthesis:\r
                 InParenthesis -= 1\r
             else:\r
                 raise BadExpression(ERR_STRING_TOKEN % Item)\r
-        if ch == '"' and not InSingleQuote:\r
+        elif ch == '"' and not InSingleQuote:\r
             if String[i-1] != '\\':\r
                 InDoubleQuote = not InDoubleQuote\r
-        if ch == "'" and not InDoubleQuote:\r
+        elif ch == "'" and not InDoubleQuote:\r
             if String[i-1] != '\\':\r
                 InSingleQuote = not InSingleQuote\r
-        if ch == ',':\r
+        elif ch == ',':\r
             if InParenthesis or InSingleQuote or InDoubleQuote:\r
                 Item += String[i]\r
                 continue\r