]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: move RegEx compile out of loops
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Fri, 13 Apr 2018 20:51:31 +0000 (04:51 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Tue, 17 Apr 2018 12:49:53 +0000 (20:49 +0800)
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>
BaseTools/Source/Python/Workspace/DscBuildData.py

index 2cc920696d63eda405a8b1192f2b37f7da29a319..1de3e6b2aef9051e99be2950e404c94480979628 100644 (file)
@@ -95,6 +95,9 @@ MAKEROOT ?= $(EDK_TOOLS_PATH)/Source/C
 LIBS = -lCommon\r
 '''\r
 \r
+## regular expressions for finding decimal and hex numbers\r
+Pattern = re.compile('^[1-9]\d*|0$')\r
+HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
 ## Regular expression for finding header file inclusions\r
 from AutoGen.GenMake import gIncludePattern\r
 \r
@@ -642,9 +645,7 @@ class DscBuildData(PlatformBuildClassObject):
                 if Record[1] in [None, '']:\r
                     EdkLogger.error('build', FORMAT_INVALID, 'No Sku ID name',\r
                                     File=self.MetaFile, Line=Record[-1])\r
-                Pattern = re.compile('^[1-9]\d*|0$')\r
-                HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
-                if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None:\r
+                if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):\r
                     EdkLogger.error('build', FORMAT_INVALID, "The format of the Sku ID number is invalid. It only support Integer and HexNumber",\r
                                     File=self.MetaFile, Line=Record[-1])\r
                 if not IsValidWord(Record[1]):\r
@@ -669,9 +670,7 @@ class DscBuildData(PlatformBuildClassObject):
                 if Record[1] in [None, '']:\r
                     EdkLogger.error('build', FORMAT_INVALID, 'No DefaultStores ID name',\r
                                     File=self.MetaFile, Line=Record[-1])\r
-                Pattern = re.compile('^[1-9]\d*|0$')\r
-                HexPattern = re.compile(r'0[xX][0-9a-fA-F]+$')\r
-                if Pattern.match(Record[0]) is None and HexPattern.match(Record[0]) is None:\r
+                if not Pattern.match(Record[0]) and not HexPattern.match(Record[0]):\r
                     EdkLogger.error('build', FORMAT_INVALID, "The format of the DefaultStores ID number is invalid. It only support Integer and HexNumber",\r
                                     File=self.MetaFile, Line=Record[-1])\r
                 if not IsValidWord(Record[1]):\r