diff options
author | Carsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben> | 2018-03-17 07:27:44 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-03-29 16:20:22 +0800 |
commit | 018f7b827fa4def3476f76cdf1d6400d4a8e6ebc (patch) | |
tree | a7d339420c0ce501acd6c4ddd1eab36d1c884b37 /BaseTools/Source/Python | |
parent | b1a9e404d4e91729b99d690fa849451269dd3a47 (diff) | |
download | edk2-018f7b827fa4def3476f76cdf1d6400d4a8e6ebc.tar.gz edk2-018f7b827fa4def3476f76cdf1d6400d4a8e6ebc.tar.bz2 edk2-018f7b827fa4def3476f76cdf1d6400d4a8e6ebc.zip |
BaseTools: Use precompiled RegExp
avoid recompiling the regular expression for each use in a while loop
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>
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r-- | BaseTools/Source/Python/AutoGen/UniClassObject.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 856d19cda2..5b674dfbc2 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -4,7 +4,7 @@ #
# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>
#
-# Copyright (c) 2007 - 2016, 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
# which accompanies this distribution. The full text of the license may be found at
@@ -24,6 +24,7 @@ from Common.BuildToolError import * from Common.String import GetLineNo
from Common.Misc import PathClass
from Common.LongFilePathSupport import LongFilePath
+from Common.GlobalData import *
##
# Static definitions
#
@@ -436,11 +437,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:]
|