From 4e375707392e4f9085e2d2342e41aee9d4df2b0a Mon Sep 17 00:00:00 2001 From: BobCF Date: Thu, 8 Nov 2018 18:16:25 +0800 Subject: BaseTools: Optimize string concatenation 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 use join function instead of string += string2 statement. Current code use string += string2 in a loop to combine a string. while creating a string list in a loop and using "".join(stringlist) after the loop will be much faster. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey Reviewed-by: Liming Gao Reviewed-by: Jaben Carsey --- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'BaseTools/Source/Python/Workspace/WorkspaceCommon.py') diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index 8d8a3e2789..55d01fa4b2 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -128,13 +128,10 @@ def GetModuleLibInstances(Module, Platform, BuildDatabase, Arch, Target, Toolcha for LibraryClassName in M.LibraryClasses: if LibraryClassName not in LibraryInstance: # override library instance for this module - if LibraryClassName in Platform.Modules[str(Module)].LibraryClasses: - LibraryPath = Platform.Modules[str(Module)].LibraryClasses[LibraryClassName] - else: - LibraryPath = Platform.LibraryClasses[LibraryClassName, ModuleType] - if LibraryPath is None or LibraryPath == "": - LibraryPath = M.LibraryClasses[LibraryClassName] - if LibraryPath is None or LibraryPath == "": + LibraryPath = Platform.Modules[str(Module)].LibraryClasses.get(LibraryClassName,Platform.LibraryClasses[LibraryClassName, ModuleType]) + if LibraryPath is None: + LibraryPath = M.LibraryClasses.get(LibraryClassName) + if LibraryPath is None: if FileName: EdkLogger.error("build", RESOURCE_NOT_AVAILABLE, "Instance of library class [%s] is not found" % LibraryClassName, -- cgit v1.2.3