From: "bob.c.f...@intel.com" <bob.c.f...@intel.com> https://bugzilla.tianocore.org/show_bug.cgi?id=1288
This patch is one of build tool performance improvement series patches. This patch is going to add cache for UniToHexList function. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF <bob.c.f...@intel.com> Cc: Liming Gao <liming....@intel.com> Cc: Jaben Carsey <jaben.car...@intel.com> --- BaseTools/Source/Python/AutoGen/UniClassObject.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py index 384f31b165..e889af9e82 100644 --- a/BaseTools/Source/Python/AutoGen/UniClassObject.py +++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py @@ -43,10 +43,11 @@ LF = u'\u000A' NULL = u'\u0000' TAB = u'\t' BACK_SLASH_PLACEHOLDER = u'\u0006' gIncludePattern = re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", re.MULTILINE | re.UNICODE) +UniTokenCache = dict() ## Convert a python unicode string to a normal string # # Convert a python unicode string to a normal string # UniToStr(u'I am a string') is 'I am a string' @@ -66,16 +67,18 @@ def UniToStr(Uni): # @param Uni: The python unicode string # # @retval List: The formatted hex list # def UniToHexList(Uni): - List = [] - for Item in Uni: - Temp = '%04X' % ord(Item) - List.append('0x' + Temp[2:4]) - List.append('0x' + Temp[0:2]) - return List + if Uni not in UniTokenCache: + List = [] + for Item in Uni: + Temp = '%04X' % ord(Item) + List.append('0x' + Temp[2:4]) + List.append('0x' + Temp[0:2]) + UniTokenCache[Uni] = List + return UniTokenCache[Uni] LangConvTable = {'eng':'en', 'fra':'fr', \ 'aar':'aa', 'abk':'ab', 'ave':'ae', 'afr':'af', 'aka':'ak', 'amh':'am', \ 'arg':'an', 'ara':'ar', 'asm':'as', 'ava':'av', 'aym':'ay', 'aze':'az', \ 'bak':'ba', 'bel':'be', 'bul':'bg', 'bih':'bh', 'bis':'bi', 'bam':'bm', \ -- 2.19.1.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel