summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
diff options
context:
space:
mode:
authorJeremy Compostella <jeremy.compostella@intel.com>2025-11-26 21:35:13 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-12-02 05:21:22 +0300
commit3af7eccf472d2308201fccc805db7e06acabd47c (patch)
treef0a44eafa4e8bb073233caa3f6b12d1a6ab44b2e /BaseTools/Source/Python
parent43e86ce5d5fcca1c4b6b45067ccd8a6cfab0e2b5 (diff)
downloadedk2-3af7eccf472d2308201fccc805db7e06acabd47c.tar.xz
BaseTools: AutoGen: Optimize tuple creation using tuple() for PcdDbBuffer
Replace manual loop-based tuple construction with the built-in tuple() function when converting PcdDbBuffer to a tuple. This change significantly improves performance—approximately three times faster—resulting in substantial build time savings in large environments. Previously, the code iterated over each byte in PcdDbBuffer, unpacking and appending it to a tuple. The new approach leverages tuple(PcdDbBuffer) to achieve the same result more efficiently. The generated tuple remains identical to the original implementation. TEST=The generated tuple is the same than with to original code Signed-off-by: Jeremy Compostella <jeremy.compostella@intel.com>
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r--BaseTools/Source/Python/AutoGen/GenPcdDb.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
index 28df647bfe..d2cac62d1c 100644
--- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py
+++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.py
@@ -942,9 +942,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform, Phase):
if DynamicPcdSet_Sku:
for skuname, skuid in DynamicPcdSet_Sku:
AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer, VarCheckTab = CreatePcdDatabasePhaseSpecificAutoGen (Platform, DynamicPcdSet_Sku[(skuname, skuid)], Phase)
- final_data = ()
- for item in range(len(PcdDbBuffer)):
- final_data += unpack("B", PcdDbBuffer[item:item+1])
+ final_data = tuple(PcdDbBuffer)
PcdDBData[(skuname, skuid)] = (PcdDbBuffer, final_data)
PcdDriverAutoGenData[(skuname, skuid)] = (AdditionalAutoGenH, AdditionalAutoGenC)
VarCheckTableData[(skuname, skuid)] = VarCheckTab
@@ -955,9 +953,7 @@ def NewCreatePcdDatabasePhaseSpecificAutoGen(Platform, Phase):
AdditionalAutoGenH, AdditionalAutoGenC = CreateAutoGen(PcdDriverAutoGenData)
else:
AdditionalAutoGenH, AdditionalAutoGenC, PcdDbBuffer, VarCheckTab = CreatePcdDatabasePhaseSpecificAutoGen (Platform, {}, Phase)
- final_data = ()
- for item in range(len(PcdDbBuffer)):
- final_data += unpack("B", PcdDbBuffer[item:item + 1])
+ final_data = tuple(PcdDbBuffer)
PcdDBData[(TAB_DEFAULT, "0")] = (PcdDbBuffer, final_data)
return AdditionalAutoGenH, AdditionalAutoGenC, CreatePcdDataBase(PcdDBData)