Reviewed-by: Yonghong Zhu <[email protected]> Best Regards, Zhu Yonghong
-----Original Message----- From: Carsey, Jaben Sent: Tuesday, March 27, 2018 8:33 AM To: [email protected] Cc: Gao, Liming <[email protected]>; Zhu, Yonghong <[email protected]> Subject: [PATCH v1 1/1] BaseTools: refactor repeated RegExp when no special searching is needed. use str.replace and try/except. Cc: Liming Gao <[email protected]> Cc: Yonghong Zhu <[email protected]> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <[email protected]> --- BaseTools/Source/Python/Common/Expression.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 4f0f377f3788..b7500bff9051 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -938,12 +938,13 @@ class ValueExpressionEx(ValueExpression): OffsetList = ReOffset.findall(Item) except: pass + # replace each offset, except errors for Offset in OffsetList: - if Offset in LabelDict.keys(): - Re = re.compile('OFFSET_OF\(%s\)' % Offset) - Item = Re.sub(LabelDict[Offset], Item) - else: + try: + Item = Item.replace('OFFSET_OF({})'.format(Offset),LabelDict[Offset]) + except: raise BadExpression('%s not defined' % Offset) + NewPcdValueList.append(Item) AllPcdValueList = [] -- 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

