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.65; helo=mga03.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (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 DB464226612A5 for ; Wed, 25 Apr 2018 01:52:13 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2018 01:52:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,325,1520924400"; d="scan'208";a="35118208" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga008.fm.intel.com with ESMTP; 25 Apr 2018 01:52:13 -0700 Received: from fmsmsx112.amr.corp.intel.com (10.18.116.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Apr 2018 01:52:13 -0700 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX112.amr.corp.intel.com (10.18.116.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 25 Apr 2018 01:52:12 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.210]) by shsmsx102.ccr.corp.intel.com ([169.254.2.79]) with mapi id 14.03.0319.002; Wed, 25 Apr 2018 16:52:10 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto initialize Thread-Index: AQHT2L+NiHfzZXTsZkiAWnOrDcHUfqQRM+LQ Date: Wed, 25 Apr 2018 08:52:10 +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 25/27] BaseTools: AutoGen - use defaultdict to auto initialize 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: , X-List-Received-Date: Wed, 25 Apr 2018 08:52:14 -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, April 20, 2018 11:52 PM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v1 25/27] BaseTools: AutoGen - use defaultdict to auto init= ialize Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/AutoGen/GenVar.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/GenVar.py b/BaseTools/Source/P= ython/AutoGen/GenVar.py index 37c168a84b43..99c6ed640c00 100644 --- a/BaseTools/Source/Python/AutoGen/GenVar.py +++ b/BaseTools/Source/Python/AutoGen/GenVar.py @@ -128,7 +128,7 @@ class VariableMgr(object): return var_value def process_variable_data(self): =20 - var_data =3D dict() + var_data =3D collections.defaultdict(collections.OrderedDict) =20 indexedvarinfo =3D collections.OrderedDict() for item in self.VarInfo: @@ -155,8 +155,6 @@ class VariableMgr(object): for item in default_data_buffer: default_data_array +=3D unpack("B",item) =20 - if (DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEFAULT) = not in var_data: - var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES= _DEFAULT)] =3D collections.OrderedDict() var_data[(DataType.TAB_DEFAULT,DataType.TAB_DEFAULT_STORES_DEF= AULT)][index] =3D (default_data_buffer,sku_var_info[(DataType.TAB_DEFAULT,D= ataType.TAB_DEFAULT_STORES_DEFAULT)]) =20 for (skuid,defaultstoragename) in indexedvarinfo.get(index): @@ -177,8 +175,6 @@ class VariableMgr(object): =20 data_delta =3D self.calculate_delta(default_data_array, ot= hers_data_array) =20 - if (skuid,defaultstoragename) not in var_data: - var_data[(skuid,defaultstoragename)] =3D collections.O= rderedDict() var_data[(skuid,defaultstoragename)][index] =3D (data_delt= a,sku_var_info[(skuid,defaultstoragename)]) return var_data =20 --=20 2.16.2.windows.1