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 1m1Yat-0002tr-HS for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jul 2021 18:17:51 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m1Yar-0006qG-Rv for pgsql-hackers@arkaria.postgresql.org; Thu, 08 Jul 2021 18:17:49 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1Yaq-0006q7-Mg for pgsql-hackers@lists.postgresql.org; Thu, 08 Jul 2021 18:17:49 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m1Yao-00007h-5v for pgsql-hackers@lists.postgresql.org; Thu, 08 Jul 2021 18:17:47 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 30E0D5C005B; Thu, 8 Jul 2021 14:17:45 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 08 Jul 2021 14:17:45 -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:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=VHMZGPVZf6dWQhjPtx4RJvUwesp2NeSB5AYdOH2OSIo=; b=RFSDh7K3 KFYT87yaZliDQNxWrIpoW9B+jQE+3JycGwf2IjznK1XDc2IzoW0O1RuqjKKAPTrp KZYUg5rQC2lgOBdLCCUptXeoikM9gPo8w3Iod3J2LqyIqNiTWprvkbJPNfD5sWzF 52GMwDNg/eK+oTmcIYeCExTYHWWmjn5dfbbPy+vXxrVCqVv+OG/wNW89bUOD1oV0 Be2KkuWm1rM5SXCaBB/5RnCYzVAseV3dzk36xBS4ag5Q80kQBQAv1qCWZ0s7QyhV qhgJiSgqy9is8TPb+3dj3IsAzJhSiMrtmKs0t/UWksi7kJmnUW0nyPAqEIjTN6F6 roVBJzkGXS3UTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrtdeggdduudelucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehtkeertddttdejnecuhfhrohhmpeetlhhvrghr ohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhgqe enucggtffrrghtthgvrhhnpedujeevjeffjeevuddutedvkeeiueeitddvieelfeekveej udefgeeuvdejhfeuleenucffohhmrghinhepvghnthgvrhhprhhishgvuggsrdgtohhmne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 8 Jul 2021 14:17:44 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 42D642A0999; Thu, 8 Jul 2021 14:17:41 -0400 (-04) Date: Thu, 8 Jul 2021 14:17:41 -0400 From: Alvaro Herrera To: Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?= Cc: PostgreSQL Hackers Subject: Re: Replace remaining =?utf-8?B?Y2FzdE5vZGUo4oCmLCBsZmlyc3Qo4oCm?= =?utf-8?B?KSk=?= and friends calls with l*_node() Message-ID: <202107081817.mkd7in7le6qr@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87eecahraj.fsf@wibble.ilmari.org> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk +1 on the idea. On a quick glance, all changes looks good. On 2021-Jul-07, Dagfinn Ilmari Mannsåker 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. > @@ -11990,7 +11990,7 @@ get_range_partbound_string(List *bound_datums) > foreach(cell, bound_datums) > { > PartitionRangeDatum *datum = > - castNode(PartitionRangeDatum, lfirst(cell)); > + lfirst_node(PartitionRangeDatum, cell); This is pretty personal and subjective, but stylistically I dislike initializations that indent to the same level as the variable declarations they follow; they still require a second line of code and don't look good when in between other declarations. The style is at odds with what pgindent does when the assignment is not an initialization. We seldom use this style. In this particular case it is possible to split more cleanly while ending up with exactly the same line count by removing the initialization and making it a straight assignment, foreach(cell, bound_datums) { PartitionRangeDatum *datum; datum = lfirst_node(PartitionRangeDatum, cell); appendStringInfoString(buf, sep); if (datum->kind == PARTITION_RANGE_DATUM_MINVALUE) This doesn't bother me enough to change on its own, but if we're modifying the same line here, we may as well clean this up. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "No deja de ser humillante para una persona de ingenio saber que no hay tonto que no le pueda enseñar algo." (Jean B. Say)