]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Use precompiled RegExp
authorCarsey, Jaben </o=Intel/ou=Americas01/cn=Workers/cn=Carsey, Jaben>
Fri, 16 Mar 2018 23:27:44 +0000 (07:27 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Thu, 29 Mar 2018 08:20:22 +0000 (16:20 +0800)
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>
BaseTools/Source/Python/AutoGen/UniClassObject.py

index 856d19cda270cdc64b84812f578860f2a35a4c1f..5b674dfbc2f0a04cf6ee3728b072b04efa97f5d0 100644 (file)
@@ -4,7 +4,7 @@
 #\r
 # Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -24,6 +24,7 @@ from Common.BuildToolError import *
 from Common.String import GetLineNo\r
 from Common.Misc import PathClass\r
 from Common.LongFilePathSupport import LongFilePath\r
+from Common.GlobalData import *\r
 ##\r
 # Static definitions\r
 #\r
@@ -436,11 +437,11 @@ class UniFileClassObject(object):
             while (StartPos != -1):\r
                 EndPos = Line.find(u'\\', StartPos + 1, StartPos + 7)\r
                 if EndPos != -1 and EndPos - StartPos == 6 :\r
-                    if re.match('[a-fA-F0-9]{4}', Line[StartPos + 2 : EndPos], re.UNICODE):\r
+                    if g4HexChar.match(Line[StartPos + 2 : EndPos], re.UNICODE):\r
                         EndStr = Line[EndPos: ]\r
                         UniStr = ('\u' + (Line[StartPos + 2 : EndPos])).decode('unicode_escape')\r
                         if EndStr.startswith(u'\\x') and len(EndStr) >= 7:\r
-                            if EndStr[6] == u'\\' and re.match('[a-fA-F0-9]{4}', EndStr[2 : 6], re.UNICODE):\r
+                            if EndStr[6] == u'\\' and g4HexChar.match(EndStr[2 : 6], re.UNICODE):\r
                                 Line = Line[0 : StartPos] + UniStr + EndStr\r
                         else:\r
                             Line = Line[0 : StartPos] + UniStr + EndStr[1:]\r