Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvcRW-006Gea-Qs for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Oct 2023 11:52:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qvcRV-002uG7-81 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Oct 2023 11:52:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvcRU-002uFz-Ll for pgsql-hackers@lists.postgresql.org; Wed, 25 Oct 2023 11:52:56 +0000 Received: from wout1-smtp.messagingengine.com ([64.147.123.24]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qvcRQ-002doh-65 for pgsql-hackers@postgresql.org; Wed, 25 Oct 2023 11:52:55 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id E20BC320099D; Wed, 25 Oct 2023 07:52:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 25 Oct 2023 07:52:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1698234768; x= 1698321168; bh=S3c3Lw3lHJI9/GorUe6QwZjANdfCkgwBWVkD23HLOUk=; b=Q kSGUHgiXu3fNlKJfLQ3MIKnpjs8jaXnDzyIu8uvpTBiDoGr0qmodx8L8sLNV7Xij 34uGgubgthJpXq4/OzGWTamcE2z/N4Z9kgPn1CtMem8yi1bJIR4y66HLpa4km1yw km7uNjWQ7ZtWC5+XV8agWpB/ENzCWJEayNIDxTNDbrE+hV/sMcXpi/AiqZYebW9H nrV4ay3rLfRNfYsfGxQF7DrW0FszaV2jPvk/9MO4rS7zIC5v09o1/47GTp5Lp8BX YDtUsHpe12et0JYO+cKvPfpGPrkK0aAhZ/xUW2lblA00zyC7Cdm9IGkCdjHjU5o3 sKY08VYnYqWFPV5y3v4Vg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrledtgdeghecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhepfffhvfevuffkgggtugfgjgesthekre dttddtjeenucfhrhhomheptehlvhgrrhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgv segrlhhvhhdrnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepvdektdffudfftd ffffehfffhjeejhffgieeuueekjeekfffgudffhfduffffueevnecuffhomhgrihhnpegv nhhtvghrphhrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Feedback-ID: ia2694551:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Oct 2023 07:52:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alvh.no-ip.org; s=schmee; t=1698223915; bh=pO2KYDcR7z4Bx/YEz0izkGzB+AR++V5fqa6s6/J/1TI=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Iv/ztdAUrs35xtIvk2aqO9WlNrhzLTOz0kQ/heWMpN2d4UjTB9G7RxqFAomfX5jDY F3qhHCo47hx0OwqTMbsWewdVgMJvZ2aRDqbUmoMCNRoByliq+XTr7DTMETt/mtGv9U ZEwH7gc3uiu1FeU+7T8jSInKp0/Qu3F4lcNaEn8Dm4Q9KWMvWi74DA0gLuJvlOoz6D srwXXVAfwS1mhIHROboIF5u/i+AhpYoGQ9+ZvOI4sirh6I22kmeE+f4LtXnzbS8mQL 8UmksDDQVEjlJMrY/QdwZKtnHmYHXI/r0e8Nx7JqqXEF5T8PvWAfCQcN3ZFJyuqjXI uxdm6S4LpkiwA== Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id F0A0DC9; Wed, 25 Oct 2023 10:51:55 +0200 (CEST) Date: Wed, 25 Oct 2023 10:51:55 +0200 From: Alvaro Herrera To: Jelte Fennema Cc: PostgreSQL-development Subject: Re: Add new for_each macros for iterating over a List that do not require ListCell pointer Message-ID: <202310250851.3wmj444nmqf6@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2023-Oct-24, Jelte Fennema wrote: > Many usages of the foreach macro in the Postgres codebase only use the > ListCell variable to then get its value. This adds macros that > simplify iteration code for that very common use case. Instead of > passing a ListCell you can pass a variable of the type of its > contents. This IMHO improves readability of the code by reducing the > total amount of code while also essentially forcing the use of useful > variable names. +1 for getting rid of useless "lc" variables. Looking at for_each_ptr() I think it may be cleaner to follow palloc_object()'s precedent and make it foreach_object() instead (I have no love for the extra underscore, but I won't object to it either). And like foreach_node, have it receive a type name to add a cast to. I'd imagine something like SubscriptionRelState *rstate; foreach_object(SubscriptionRelState *, rstate, table_states_not_ready) { -- Álvaro Herrera 48°01'N 7°57'E — https://www.EnterpriseDB.com/