From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Yonghong Zhu <yonghong.zhu@intel.com>
Subject: [PATCH v1 1/3] BaseTools: use single RegExp for token matching
Date: Thu, 29 Mar 2018 14:38:06 -0700 [thread overview]
Message-ID: <ab5101eccf3153f6db9a8f6be43122b05952aa43.1522359411.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1522359411.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1522359411.git.jaben.carsey@intel.com>
same pattern was compiled 3 places in the file. just compile once and share.
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/FdfParserLite.py | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py
index b7b5e21a9e3f..c22711603233 100644
--- a/BaseTools/Source/Python/Common/FdfParserLite.py
+++ b/BaseTools/Source/Python/Common/FdfParserLite.py
@@ -49,6 +49,7 @@ InputMacroDict = {}
AllMacroList = []
FileExtensionPattern = re.compile(r'([a-zA-Z][a-zA-Z0-9]*)')
+TokenFindPattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
def GetRealFileLine (File, Line):
@@ -2094,8 +2095,7 @@ class FdfParser(object):
if self.__GetNextToken():
- p = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
- if p.match(self.__Token):
+ if TokenFindPattern.match(self.__Token):
FfsInfObj.KeyStringList.append(self.__Token)
if not self.__IsToken(","):
return
@@ -2104,7 +2104,7 @@ class FdfParser(object):
return
while self.__GetNextToken():
- if not p.match(self.__Token):
+ if not TokenFindPattern.match(self.__Token):
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
FfsInfObj.KeyStringList.append(self.__Token)
@@ -2252,12 +2252,11 @@ class FdfParser(object):
def __GetFileOpts(self, FfsFileObj):
if self.__GetNextToken():
- Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
- if Pattern.match(self.__Token):
+ if TokenFindPattern.match(self.__Token):
FfsFileObj.KeyStringList.append(self.__Token)
if self.__IsToken(","):
while self.__GetNextToken():
- if not Pattern.match(self.__Token):
+ if not TokenFindPattern.match(self.__Token):
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
FfsFileObj.KeyStringList.append(self.__Token)
@@ -2902,12 +2901,11 @@ class FdfParser(object):
KeyStringList = []
if self.__GetNextToken():
- Pattern = re.compile(r'([a-zA-Z0-9\-]+|\$\(TARGET\)|\*)_([a-zA-Z0-9\-]+|\$\(TOOL_CHAIN_TAG\)|\*)_([a-zA-Z0-9\-]+|\$\(ARCH\)|\*)')
- if Pattern.match(self.__Token):
+ if TokenFindPattern.match(self.__Token):
KeyStringList.append(self.__Token)
if self.__IsToken(","):
while self.__GetNextToken():
- if not Pattern.match(self.__Token):
+ if not TokenFindPattern.match(self.__Token):
raise Warning("expected KeyString \"Target_Tag_Arch\" At Line ", self.FileName, self.CurrentLineNumber)
KeyStringList.append(self.__Token)
--
2.16.2.windows.1
next prev parent reply other threads:[~2018-03-29 21:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 21:38 [PATCH v1 0/3] BaseTools: reduce RegExp compile times Jaben Carsey
2018-03-29 21:38 ` Jaben Carsey [this message]
2018-03-29 21:38 ` [PATCH v1 2/3] BaseTools: use new RegEx from FdfParserLite Jaben Carsey
2018-03-29 21:38 ` [PATCH v1 3/3] BaseTools: fix comment cut/paste error Jaben Carsey
2018-04-03 9:26 ` [PATCH v1 0/3] BaseTools: reduce RegExp compile times Zhu, Yonghong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab5101eccf3153f6db9a8f6be43122b05952aa43.1522359411.git.jaben.carsey@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox