Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3ItE-0007jR-NL for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jul 2021 13:56:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m3ItD-0003S6-Ge for pgsql-hackers@arkaria.postgresql.org; Tue, 13 Jul 2021 13:55:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3ItD-0003Ry-8T for pgsql-hackers@lists.postgresql.org; Tue, 13 Jul 2021 13:55:59 +0000 Received: from wforward2-smtp.messagingengine.com ([64.147.123.31]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3It9-0007OQ-Kf for pgsql-hackers@lists.postgresql.org; Tue, 13 Jul 2021 13:55:58 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailforward.west.internal (Postfix) with ESMTP id E19151AC1AF8; Tue, 13 Jul 2021 09:55:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Tue, 13 Jul 2021 09:55:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=f562A4qJiDLGPLAcDA70Jf2C2vibBf45XKZtUhWjZ gQ=; b=nvFwHsWvQmGs5mc3x+5ppI6BSYa//ZluA8hi4RRi+hIMPNDdBjiLeBbO2 3APGbC/A+UBSsD9rH143s5M0g0UzWvX6gwmkXiQCKHtcBxNDa/o/kYd8KyuVcld1 dug+XFYHPMMm2cYsDLr7AkOBq+hH6n6a5qfbfEAHbj4l+B8wMMkzAL3r5HAAAuCv 5hBN7G2Qpq/Jeh/DOM/BG0j6D8VpIpkN3/rTYRlBe2fLVxcQpsBupKGjlTvroSd4 XkESJH7FLJ0EQZJiM7QMaj00EoAGZ80zR6pKDKW7CC2r5PuLzN8aYk8Dl0HjLH/F XtUuoToFcdV1n8D/a3SFHPdKvlzUw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudehgdeitdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefuvfhfhffkffgfgggjtgfgsehtjeertddtfeejnecuhfhrohhmpefrvghtvghr ucfgihhsvghnthhrrghuthcuoehpvghtvghrrdgvihhsvghnthhrrghuthesvghnthgvrh hprhhishgvuggsrdgtohhmqeenucggtffrrghtthgvrhhnpeelveehheeuieduieetiedt keeuteelfeetjeffieffudegvdffvdfftdeivdeukeenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpvghtvghrrdgvihhsvghnthhrrghuthes vghnthgvrhhprhhishgvuggsrdgtohhm X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 13 Jul 2021 09:55:51 -0400 (EDT) Subject: =?UTF-8?Q?Re=3a_Replace_remaining_castNode=28=e2=80=a6=2c_lfirst=28?= =?UTF-8?B?4oCmKSkgYW5kIGZyaWVuZHMgY2FsbHMgd2l0aCBsKl9ub2RlKCk=?= To: Alvaro Herrera , =?UTF-8?Q?Dagfinn_Ilmari_Manns=c3=a5ker?= Cc: PostgreSQL Hackers References: <202107081817.mkd7in7le6qr@alvherre.pgsql> From: Peter Eisentraut Message-ID: <4c9836e2-ed0b-28a4-1cae-fb448a1af362@enterprisedb.com> Date: Tue, 13 Jul 2021 15:55:48 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <202107081817.mkd7in7le6qr@alvherre.pgsql> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 08.07.21 20:17, Alvaro Herrera wrote: >> diff --git a/src/backend/rewrite/rewriteSearchCycle.c b/src/backend/rewrite/rewriteSearchCycle.c >> index 599fe8e735..c50ebdba24 100644 >> --- a/src/backend/rewrite/rewriteSearchCycle.c >> +++ b/src/backend/rewrite/rewriteSearchCycle.c >> @@ -307,8 +307,8 @@ rewriteSearchAndCycle(CommonTableExpr *cte) >> list_nth_oid(cte->ctecolcollations, i), >> 0); >> tle = makeTargetEntry((Expr *) var, i + 1, strVal(list_nth(cte->ctecolnames, i)), false); >> - tle->resorigtbl = castNode(TargetEntry, list_nth(rte1->subquery->targetList, i))->resorigtbl; >> - tle->resorigcol = castNode(TargetEntry, list_nth(rte1->subquery->targetList, i))->resorigcol; >> + tle->resorigtbl = list_nth_node(TargetEntry, rte1->subquery->targetList, i)->resorigtbl; >> + tle->resorigcol = list_nth_node(TargetEntry, rte1->subquery->targetList, i)->resorigcol; > This seems a bit surprising to me. I mean, clearly we trust our List > implementation to be so good that we can just fetch the same node twice, > one for each member of the same struct, and the compiler will optimize > everything so that it's a single access to the n'th list entry. Is this > true? I would have expected there to be a single fetch of the struct, > followed by an access of each of the two struct members. Lists are arrays now internally, so accessing an element by number is pretty cheap.