summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/Workspace/DscBuildData.py
diff options
context:
space:
mode:
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>2018-04-14 04:51:31 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-04-17 20:49:53 +0800
commitfe1abb4beb23a44820b028722c636050ccbc9c34 (patch)
tree1facbd7731c4aa26b077ac8036419c6adcb4ed22 /BaseTools/Source/Python/Workspace/DscBuildData.py
parenta6c910e3583c0124e4ba0d42004003fff036e160 (diff)
downloadedk2-fe1abb4beb23a44820b028722c636050ccbc9c34.tar.gz
edk2-fe1abb4beb23a44820b028722c636050ccbc9c34.tar.bz2
edk2-fe1abb4beb23a44820b028722c636050ccbc9c34.zip
BaseTools: move RegEx compile out of loops
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>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/DscBuildData.py')
-rw-r--r--BaseTools/Source/Python/Workspace/DscBuildData.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 2cc920696d..1de3e6b2ae 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -95,6 +95,9 @@ MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C
LIBS = -lCommon
'''
+## regular expressions for finding decimal and hex numbers
+Pattern = re.compile('^[1-9]\d*|0$')
+HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
## Regular expression for finding header file inclusions
from AutoGen.GenMake import gIncludePattern
@@ -642,9 +645,7 @@ class DscBuildData(PlatformBuildClassObject):
if Record[1] in [None, '']:
EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID name',
File=self.MetaFile, Line=Record[-1])
- Pattern = re.compile('^[1-9]\d*|0$')
- HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
- if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None:
+ if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",
File=self.MetaFile, Line=Record[-1])
if not IsValidWord(Record[1]):
@@ -669,9 +670,7 @@ class DscBuildData(PlatformBuildClassObject):
if Record[1] in [None, '']:
EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name',
File=self.MetaFile, Line=Record[-1])
- Pattern = re.compile('^[1-9]\d*|0$')
- HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')
- if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None:
+ if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):
EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber",
File=self.MetaFile, Line=Record[-1])
if not IsValidWord(Record[1]):