From bf9e636605188e291d33ab694ff1c5926b6f0800 Mon Sep 17 00:00:00 2001 From: BobCF Date: Thu, 8 Nov 2018 14:03:38 +0800 Subject: BaseTools: Customize deepcopy function. 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 customize the deepcopy function for SkuClass, PcdClassObject and python dictionary. python deepcopy copy everything of a object, but for our current usage we just need to copy the data we care about recursively. By implementing __deepcopy__ for SkuClass, PcdClassObject, we can customize deepcopy function for them. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: BobCF Cc: Liming Gao Cc: Jaben Carsey Reviewed-by: Jaben Carsey Reviewed-by: Liming Gao --- BaseTools/Source/Python/CommonDataClass/CommonClass.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'BaseTools/Source/Python/CommonDataClass/CommonClass.py') diff --git a/BaseTools/Source/Python/CommonDataClass/CommonClass.py b/BaseTools/Source/Python/CommonDataClass/CommonClass.py index a98cf8a7c5..336bb11671 100644 --- a/BaseTools/Source/Python/CommonDataClass/CommonClass.py +++ b/BaseTools/Source/Python/CommonDataClass/CommonClass.py @@ -80,3 +80,18 @@ class SkuInfoClass(object): 'VpdOffset = ' + str(self.VpdOffset) + "," + \ 'DefaultValue = ' + str(self.DefaultValue) + "," return Rtn + + def __deepcopy__(self,memo): + new_sku = SkuInfoClass() + new_sku.SkuIdName = self.SkuIdName + new_sku.SkuId = self.SkuId + new_sku.VariableName = self.VariableName + new_sku.VariableGuid = self.VariableGuid + new_sku.VariableGuidValue = self.VariableGuidValue + new_sku.VariableOffset = self.VariableOffset + new_sku.HiiDefaultValue = self.HiiDefaultValue + new_sku.VariableAttribute = self.VariableAttribute + new_sku.DefaultStoreDict = {key:value for key,value in self.DefaultStoreDict.items()} + new_sku.VpdOffset = self.VpdOffset + new_sku.DefaultValue = self.DefaultValue + return new_sku -- cgit v1.2.3