From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 E61D821CB8662 for ; Wed, 28 Mar 2018 19:49:10 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Mar 2018 19:55:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,374,1517904000"; d="scan'208";a="46183886" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga002.jf.intel.com with ESMTP; 28 Mar 2018 19:55:49 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 28 Mar 2018 19:55:49 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 28 Mar 2018 19:55:48 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.235]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.226]) with mapi id 14.03.0319.002; Thu, 29 Mar 2018 10:55:46 +0800 From: "Zhu, Yonghong" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH v1 3/4] BaseTools: move regular expression compile out of function call. Thread-Index: AQHTxiVW1LnYVtN19kSFmSMG4aEfVaPmho9g Date: Thu, 29 Mar 2018 02:55:46 +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 3/4] BaseTools: move regular expression compile out of function call. 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: Thu, 29 Mar 2018 02:49:11 -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: Wednesday, March 28, 2018 7:43 AM To: edk2-devel@lists.01.org Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH v1 3/4] BaseTools: move regular expression compile out of f= unction call. move to the root of the file and dont recompile. Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/Expression.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 3f2b43118553..340c50ebe00f 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -41,6 +41,8 @@ ERR_EMPTY_EXPR =3D 'Empty expression is not allo= wed.' ERR_IN_OPERAND =3D 'Macro after IN operator can only be: $(FAMILY= ), $(ARCH), $(TOOL_CHAIN_TAG) and $(TARGET).' =20 __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') +_ReLabel =3D re.compile('LABEL\((\w+)\)') _ReOffset =3D=20 +re.compile('OFFSET_OF\((\w+)\)') =20 ## SplitString # Split string to list according double quote @@ -853,13 +855,11 @@ class= ValueExpressionEx(ValueExpression): PcdValueList =3D SplitPcdValueString(PcdValue.stri= p()[1:-1]) LabelDict =3D {} NewPcdValueList =3D [] - ReLabel =3D re.compile('LABEL\((\w+)\)') - ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') LabelOffset =3D 0 for Index, Item in enumerate(PcdValueList): # compute byte offset of every LABEL - LabelList =3D ReLabel.findall(Item) - Item =3D ReLabel.sub('', Item) + LabelList =3D _ReLabel.findall(Item) + Item =3D _ReLabel.sub('', Item) Item =3D Item.strip() if LabelList: for Label in LabelList: @@ -886,11 +886,11 @@ class ValueExpressionEx(ValueExpression): # for LABEL parse Item =3D Item.strip() try: - Item =3D ReLabel.sub('', Item) + Item =3D _ReLabel.sub('', Item) except: pass try: - OffsetList =3D ReOffset.findall(Item) + OffsetList =3D _ReOffset.findall(Item) except: pass for Offset in OffsetList: -- 2.16.2.windows.1