move to the root of the file and dont recompile.
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>
---
BaseTools/Source/Python/Common/Expression.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 3f2b43118553..340c50ebe00f 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -41,6 +41,8 @@ ERR_EMPTY_EXPR = 'Empty expression is not allowed.'
ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
__ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
+_ReLabel = re.compile('LABEL\((\w+)\)')
+_ReOffset = re.compile('OFFSET_OF\((\w+)\)')
## SplitString
# Split string to list according double quote
@@ -853,13 +855,11 @@ class ValueExpressionEx(ValueExpression):
PcdValueList = SplitPcdValueString(PcdValue.strip()[1:-1])
LabelDict = {}
NewPcdValueList = []
- ReLabel = re.compile('LABEL\((\w+)\)')
- ReOffset = re.compile('OFFSET_OF\((\w+)\)')
LabelOffset = 0
for Index, Item in enumerate(PcdValueList):
# compute byte offset of every LABEL
- LabelList = ReLabel.findall(Item)
- Item = ReLabel.sub('', Item)
+ LabelList = _ReLabel.findall(Item)
+ Item = _ReLabel.sub('', Item)
Item = Item.strip()
if LabelList:
for Label in LabelList:
@@ -886,11 +886,11 @@ class ValueExpressionEx(ValueExpression):
# for LABEL parse
Item = Item.strip()
try:
- Item = ReLabel.sub('', Item)
+ Item = _ReLabel.sub('', Item)
except:
pass
try:
- OffsetList = ReOffset.findall(Item)
+ OffsetList = _ReOffset.findall(Item)
except:
pass
for Offset in OffsetList:
--
2.16.2.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Best Regards,
Zhu Yonghong
-----Original Message-----
From: Carsey, Jaben
Sent: Wednesday, March 28, 2018 7:43 AM
To: edk2-devel@lists.01.org
Cc: Gao, Liming <liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>
Subject: [PATCH v1 3/4] BaseTools: move regular expression compile out of function call.
move to the root of the file and dont recompile.
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>
---
BaseTools/Source/Python/Common/Expression.py | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py
index 3f2b43118553..340c50ebe00f 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -41,6 +41,8 @@ ERR_EMPTY_EXPR = 'Empty expression is not allowed.'
ERR_IN_OPERAND = 'Macro after IN operator can only be: $(FAMILY), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).'
__ValidString = re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$')
+_ReLabel = re.compile('LABEL\((\w+)\)') _ReOffset =
+re.compile('OFFSET_OF\((\w+)\)')
## SplitString
# Split string to list according double quote @@ -853,13 +855,11 @@ class ValueExpressionEx(ValueExpression):
PcdValueList = SplitPcdValueString(PcdValue.strip()[1:-1])
LabelDict = {}
NewPcdValueList = []
- ReLabel = re.compile('LABEL\((\w+)\)')
- ReOffset = re.compile('OFFSET_OF\((\w+)\)')
LabelOffset = 0
for Index, Item in enumerate(PcdValueList):
# compute byte offset of every LABEL
- LabelList = ReLabel.findall(Item)
- Item = ReLabel.sub('', Item)
+ LabelList = _ReLabel.findall(Item)
+ Item = _ReLabel.sub('', Item)
Item = Item.strip()
if LabelList:
for Label in LabelList:
@@ -886,11 +886,11 @@ class ValueExpressionEx(ValueExpression):
# for LABEL parse
Item = Item.strip()
try:
- Item = ReLabel.sub('', Item)
+ Item = _ReLabel.sub('', Item)
except:
pass
try:
- OffsetList = ReOffset.findall(Item)
+ OffsetList = _ReOffset.findall(Item)
except:
pass
for Offset in OffsetList:
--
2.16.2.windows.1
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2026 Red Hat, Inc.