BaseTools: FdfParser & FdfParserLite refactor regular expression for GUIDs

Instead of recompiling it each time the API is called, just use
the global one that exists.

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-16 05:39:07 +08:00 committed by Yonghong Zhu
parent 4d83616f9d
commit 2eb370ffdb
2 changed files with 5 additions and 5 deletions

View File

@ -1,7 +1,7 @@
## @file
# parse FDF file
#
# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>
#
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
@ -21,6 +21,7 @@ import Common.LongFilePathOs as os
import CommonDataClass.FdfClass
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
from Common.RangeExpression import RangeExpression
##define T_CHAR_SPACE ' '
##define T_CHAR_NULL '\0'
@ -931,8 +932,7 @@ class FdfParser(object):
if not self.__GetNextToken():
return False
p = re.compile('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')
if p.match(self.__Token) != None:
if RangeExpression.RegGuidPattern.match(self.__Token) != None:
return True
else:
self.__UndoToken()

View File

@ -59,6 +59,7 @@ import Common.LongFilePathOs as os
from Common.LongFilePathSupport import OpenLongFilePath as open
from Capsule import EFI_CERT_TYPE_PKCS7_GUID
from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID
from Common.RangeExpression import RangeExpression
##define T_CHAR_SPACE ' '
##define T_CHAR_NULL '\0'
@ -1149,8 +1150,7 @@ class FdfParser:
if not self.__GetNextToken():
return False
p = re.compile('[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}')
if p.match(self.__Token) != None:
if RangeExpression.RegGuidPattern.match(self.__Token) != None:
return True
else:
self.__UndoToken()