Re: Define variables in the approprieate scope

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Antonin Houska <ah(at)cybertec(dot)at>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Define variables in the approprieate scope
Date: 2020-03-24 00:50:55
Message-ID: 20200324005055.GC14565@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 23, 2020 at 01:00:24PM -0300, Alvaro Herrera wrote:
> On 2020-Mar-18, Bruce Momjian wrote:
>
> > On Tue, Feb 25, 2020 at 09:35:52AM +0100, Antonin Houska wrote:
> > > I've noticed that two variables in RelationCopyStorage() are defined in a
> > > scope higher than necessary. Please see the patch.
> >
> > It seems cleaner to me to allocate the variables once before the loop
> > starts, rather than for each loop iteration.
>
> If we're talking about personal preference, my own is what Antonin
> shows. However, since disagreement has been expressed, I think we
> should only change it if the generated code turns out better.

I am fine with either usage, frankly. I was just pointing out what
might be the benefit of the current coding.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EnterpriseDB https://enterprisedb.com

+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2020-03-24 01:04:24 Re: Define variables in the approprieate scope
Previous Message Andres Freund 2020-03-23 23:50:36 Autovacuum vs vac_update_datfrozenxid() vs ?