From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.126; helo=mga18.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) (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 1ADDC210C123B for ; Tue, 24 Jul 2018 00:24:21 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jul 2018 00:24:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,397,1526367600"; d="scan'208";a="56715992" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga007.fm.intel.com with ESMTP; 24 Jul 2018 00:24:14 -0700 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Jul 2018 00:24:12 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 24 Jul 2018 00:24:11 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.100]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.173]) with mapi id 14.03.0319.002; Tue, 24 Jul 2018 15:24:09 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 1/1] BaseTools: AutoGen - change class variable to funciton variable Thread-Index: AQHUH4ojihRFXRlLA0qqK9dHjLjqaqSd/3cA Date: Tue, 24 Jul 2018 07:24:09 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v1 1/1] BaseTools: AutoGen - change class variable to funciton variable X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Jul 2018 07:24:21 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, July 20, 2018 1:58 AM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v1 1/1] BaseTools: AutoGen - change class variable to funci= ton variable This variable is only used in one function, make it local there. Also when iterating on the variable, use dict.items() to get value instead = of re-looking up the value multiple times. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/GenMake.py | 25 ++++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/= Python/AutoGen/GenMake.py index 992de5490dff..f1fe5514f3f2 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -435,7 +435,6 @@ cleanlib: self.ListFileMacros =3D {} =20 self.FileCache =3D {} - self.FileDependency =3D [] self.LibraryBuildCommandList =3D [] self.LibraryFileList =3D [] self.LibraryMakefileList =3D [] @@ -890,26 +889,26 @@ cleanlib: if Item in SourceFileList: SourceFileList.remove(Item) =20 - self.FileDependency =3D self.GetFileDependency( + FileDependencyDict =3D self.GetFileDependency( SourceFileList, ForceIncludedFile, self._AutoGenObject.IncludePathList + = self._AutoGenObject.BuildOptionIncPathList ) DepSet =3D None - for File in self.FileDependency: - if not self.FileDependency[File]: - self.FileDependency[File] =3D ['$(FORCE_REBUILD)'] + for File,Dependency in FileDependencyDict.items(): + if not Dependency: + FileDependencyDict[File] =3D ['$(FORCE_REBUILD)'] continue =20 - self._AutoGenObject.AutoGenDepSet |=3D set(self.FileDependency= [File]) + self._AutoGenObject.AutoGenDepSet |=3D set(Dependency) =20 # skip non-C files if File.Ext not in [".c", ".C"] or File.Name =3D=3D "AutoGen.c= ": continue elif DepSet is None: - DepSet =3D set(self.FileDependency[File]) + DepSet =3D set(Dependency) else: - DepSet &=3D set(self.FileDependency[File]) + DepSet &=3D set(Dependency) # in case nothing in SourceFileList if DepSet is None: DepSet =3D set() @@ -919,13 +918,13 @@ cleanlib: for File in DepSet: self.CommonFileDependency.append(self.PlaceMacro(File.Path, se= lf.Macros)) =20 - for File in self.FileDependency: + for File in FileDependencyDict: # skip non-C files if File.Ext not in [".c", ".C"] or File.Name =3D=3D "AutoGen.c= ": continue - NewDepSet =3D set(self.FileDependency[File]) + NewDepSet =3D set(FileDependencyDict[File]) NewDepSet -=3D DepSet - self.FileDependency[File] =3D ["$(COMMON_DEPS)"] + list(NewDep= Set) + FileDependencyDict[File] =3D ["$(COMMON_DEPS)"] +=20 + list(NewDepSet) =20 # Convert target description object to target string in makefile for Type in self._AutoGenObject.Targets: @@ -943,8 +942,8 @@ cleanlib: for Dep in T.Dependencies: Deps.append(self.PlaceMacro(str(Dep), self.Macros)) # Add inclusion-dependencies - if len(T.Inputs) =3D=3D 1 and T.Inputs[0] in self.FileDepe= ndency: - for F in self.FileDependency[T.Inputs[0]]: + if len(T.Inputs) =3D=3D 1 and T.Inputs[0] in FileDependenc= yDict: + for F in FileDependencyDict[T.Inputs[0]]: Deps.append(self.PlaceMacro(str(F), self.Macros)) # Add source-dependencies for F in T.Inputs: -- 2.16.2.windows.1