From nobody Fri Nov 1 04:41:43 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 152340226224096.48244385995406; Tue, 10 Apr 2018 16:17:42 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id BECBF2267F115; Tue, 10 Apr 2018 16:17:28 -0700 (PDT) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5416B22618159 for ; Tue, 10 Apr 2018 16:17:27 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2018 16:17:26 -0700 Received: from jcarsey-desk1.amr.corp.intel.com ([10.7.159.141]) by orsmga003.jf.intel.com with ESMTP; 10 Apr 2018 16:17:25 -0700 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,434,1517904000"; d="scan'208";a="42343798" From: Jaben Carsey To: edk2-devel@lists.01.org Date: Tue, 10 Apr 2018 16:17:24 -0700 Message-Id: <1edee333925ff9df02022a5b0541d9b66fc1c608.1523402167.git.jaben.carsey@intel.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: References: In-Reply-To: References: Subject: [edk2] [PATCH v1 5/5] BaseTools: reduce list usage when not needed X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" remove not needed lists. some were just counted and others should be sets. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/GenC.py | 48 +++++++++++--------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Pyt= hon/AutoGen/GenC.py index 58da9e6b1784..c11bbc5716f9 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -813,7 +813,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): # AutoGen for each PCD listed in a [PcdEx] section of a Module/Lib INF= file. # Auto generate a macro for each TokenName that takes a Guid pointer a= s a parameter. =20 # Use the Guid pointer to see if it matches any of the token space GUI= Ds. - TokenCNameList =3D [] + TokenCNameList =3D set() for TokenCName in ExTokenCNameList: if TokenCName in TokenCNameList: continue @@ -836,9 +836,9 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): % (Pcd.TokenSpaceGuidCName, Pcd.TokenS= paceGuidCName, RealTokenCName)) if Index =3D=3D Count: AutoGenH.Append('0 \\\n )\n') - TokenCNameList.append(TokenCName) + TokenCNameList.add(TokenCName) =20 - TokenCNameList =3D [] + TokenCNameList =3D set() for TokenCName in ExTokenCNameList: if TokenCName in TokenCNameList: continue @@ -868,7 +868,7 @@ def DynExPcdTokenNumberMapping(Info, AutoGenH): # COMPAREGUID() will only be used if the Guid passed = in is local to the module. AutoGenH.Append('#define _PCD_TOKEN_EX_%s(GuidPtr) _= _PCD_%s_ADDR_CMP(GuidPtr) ? __PCD_%s_ADDR_CMP(GuidPtr) : __PCD_%s_VAL_CMP(G= uidPtr) \n' % (RealTokenCName, RealTokenCName, Rea= lTokenCName, RealTokenCName)) - TokenCNameList.append(TokenCName) + TokenCNameList.add(TokenCName) =20 def GetPcdSize(Pcd): if Pcd.DatumType not in _NumericDataTypesList: @@ -962,19 +962,22 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): SetModeStatusName =3D '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH[Pcd= .DatumType] + '_S_' + TokenCName if Pcd.DatumType in gDatumSizeStringDataba= seH else '_PCD_SET_MODE_' + gDatumSizeStringDatabaseH['VOID*'] + '_S_' + To= kenCName GetModeSizeName =3D '_PCD_GET_MODE_SIZE' + '_' + TokenCName =20 - PcdExCNameList =3D [] if Pcd.Type in gDynamicExPcd: if Info.IsLibrary: PcdList =3D Info.LibraryPcdList else: PcdList =3D Info.ModulePcdList + PcdExCNameTest =3D 0 for PcdModule in PcdList: - if PcdModule.Type in gDynamicExPcd: - PcdExCNameList.append(PcdModule.TokenCName) + if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName =3D=3D P= cdModule.TokenCName: + PcdExCNameTest +=3D 1 + # get out early once we found > 1... + if PcdExCNameTest > 1: + break # Be compatible with the current code which using PcdToken and Pcd= Get/Set for DynamicEx Pcd. # If only PcdToken and PcdGet/Set used in all Pcds with different = CName, it should succeed to build. # If PcdToken and PcdGet/Set used in the Pcds with different Guids= but same CName, it should failed to build. - if PcdExCNameList.count(Pcd.TokenCName) > 1: + if PcdExCNameTest > 1: AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGe= t/Set are not allowed in the case that more than one DynamicEx Pcds are dif= ferent Guids but same CName.\n') AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) @@ -996,14 +999,14 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd= ): AutoGenH.Append('#define %s(Value) LibPcdSetEx%s(&%s, %s,= (Value))\n' % (SetModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdToke= nName)) AutoGenH.Append('#define %s(Value) LibPcdSetEx%sS(&%s, %s= , (Value))\n' % (SetModeStatusName, DatumSizeLib, Pcd.TokenSpaceGuidCName, = PcdTokenName)) elif Pcd.Type in gDynamicPcd: - PcdList =3D [] - PcdCNameList =3D [] - PcdList.extend(Info.LibraryPcdList) - PcdList.extend(Info.ModulePcdList) - for PcdModule in PcdList: - if PcdModule.Type in gDynamicPcd: - PcdCNameList.append(PcdModule.TokenCName) - if PcdCNameList.count(Pcd.TokenCName) > 1: + PcdCNameTest =3D 0 + for PcdModule in Info.LibraryPcdList + Info.ModulePcdList: + if PcdModule.Type in gDynamicPcd and Pcd.TokenCName =3D=3D Pcd= Module.TokenCName: + PcdCNameTest +=3D 1 + # get out early once we found > 1... + if PcdCNameTest > 1: + break + if PcdCNameTest > 1: EdkLogger.error("build", AUTOGEN_ERROR, "More than one Dynamic= Pcds [%s] are different Guids but same CName. They need to be changed to D= ynamicEx type to avoid the confliction.\n" % (TokenCName), ExtraData=3D"[%s= ]" % str(Info.MetaFile.Path)) else: AutoGenH.Append('#define %s LibPcdGet%s(%s)\n' % (GetModeName= , DatumSizeLib, PcdTokenName)) @@ -1265,7 +1268,6 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pc= d): Type =3D '(VOID *)' Array =3D '[]' PcdItemType =3D Pcd.Type - PcdExCNameList =3D [] if PcdItemType in gDynamicExPcd: PcdExTokenName =3D '_PCD_TOKEN_' + TokenSpaceGuidCName + '_' + Tok= enCName AutoGenH.Append('\n#define %s %dU\n' % (PcdExTokenName, TokenNumb= er)) @@ -1274,13 +1276,17 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, = Pcd): PcdList =3D Info.LibraryPcdList else: PcdList =3D Info.ModulePcdList + PcdExCNameTest =3D 0 for PcdModule in PcdList: - if PcdModule.Type in gDynamicExPcd: - PcdExCNameList.append(PcdModule.TokenCName) + if PcdModule.Type in gDynamicExPcd and Pcd.TokenCName =3D=3D P= cdModule.TokenCName: + PcdExCNameTest +=3D 1 + # get out early once we found > 1... + if PcdExCNameTest > 1: + break # Be compatible with the current code which using PcdGet/Set for D= ynamicEx Pcd. # If only PcdGet/Set used in all Pcds with different CName, it sho= uld succeed to build. # If PcdGet/Set used in the Pcds with different Guids but same CNa= me, it should failed to build. - if PcdExCNameList.count(Pcd.TokenCName) > 1: + if PcdExCNameTest > 1: AutoGenH.Append('// Disabled the macros, as PcdToken and PcdGe= t/Set are not allowed in the case that more than one DynamicEx Pcds are dif= ferent Guids but same CName.\n') AutoGenH.Append('// #define %s %s\n' % (PcdTokenName, PcdExTo= kenName)) AutoGenH.Append('// #define %s LibPcdGetEx%s(&%s, %s)\n' % (G= etModeName, DatumSizeLib, Pcd.TokenSpaceGuidCName, PcdTokenName)) @@ -1696,7 +1702,7 @@ def CreatePcdCode(Info, AutoGenC, AutoGenH): AutoGenH.Append("\n// Definition of SkuId Array\n") AutoGenH.Append("extern UINT64 _gPcd_SkuId_Array[];\n") # Add extern declarations to AutoGen.h if one or more Token Space GUID= s were found - if TokenSpaceList <> []: =20 + if TokenSpaceList: AutoGenH.Append("\n// Definition of PCD Token Space GUIDs used in = this module\n\n") if Info.ModuleType in ["USER_DEFINED", "BASE"]: GuidType =3D "GUID" --=20 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel