BaseTools: Expression - change from series of if to elif

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>
This commit is contained in:
Carsey, Jaben 2018-03-14 07:11:33 +08:00 committed by Yonghong Zhu
parent 1f901a89f0
commit 3e8bab960e
1 changed files with 4 additions and 4 deletions

View File

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