avoid recompiling the regular expression for each use in a while loop
Cc: Yonghong Zhu <[email protected]>
Cc: Liming Gao <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <[email protected]>
---
BaseTools/Source/Python/AutoGen/UniClassObject.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py
b/BaseTools/Source/Python/AutoGen/UniClassObject.py
index 856d19cda270..5c653f58e4ff 100644
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
@@ -436,11 +436,11 @@ class UniFileClassObject(object):
while (StartPos != -1):
EndPos = Line.find(u'\\', StartPos + 1, StartPos + 7)
if EndPos != -1 and EndPos - StartPos == 6 :
- if re.match('[a-fA-F0-9]{4}', Line[StartPos + 2 : EndPos],
re.UNICODE):
+ if g4HexChar.match(Line[StartPos + 2 : EndPos],
re.UNICODE):
EndStr = Line[EndPos: ]
UniStr = ('\u' + (Line[StartPos + 2 :
EndPos])).decode('unicode_escape')
if EndStr.startswith(u'\\x') and len(EndStr) >= 7:
- if EndStr[6] == u'\\' and
re.match('[a-fA-F0-9]{4}', EndStr[2 : 6], re.UNICODE):
+ if EndStr[6] == u'\\' and g4HexChar.match(EndStr[2
: 6], re.UNICODE):
Line = Line[0 : StartPos] + UniStr + EndStr
else:
Line = Line[0 : StartPos] + UniStr + EndStr[1:]
--
2.16.2.windows.1
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel