Re: shadow variables - pg15 edition - Mailing list pgsql-hackers

From David Rowley
Subject Re: shadow variables - pg15 edition
Date
Msg-id CAApHDvpGZX-X=Bn4moyXgfFa0CdSUwoa04d3isit3=1qo8F8Bw@mail.gmail.com
Whole thread Raw
In response to Re: shadow variables - pg15 edition  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: shadow variables - pg15 edition
List pgsql-hackers
On Wed, 24 Aug 2022 at 22:47, David Rowley <dgrowleyml@gmail.com> wrote:
> 5. "Refactor" (fix the code to make it better)

> I have some ideas on how to fix the two #5s, so I'm going to go and do that now.

I've attached a patch which I think improves the code in
gistRelocateBuildBuffersOnSplit() so that there's no longer a shadowed
variable. I also benchmarked this method in a tight loop and can
measure no performance change from getting the loop index this way vs
the old way.

This only fixes one of the #5s I mentioned. I ended up scraping my
idea to fix the shadowed 'i' in get_qual_for_range() as it became too
complex.  The idea was to use list_cell_number() to find out how far
we looped in the forboth() loop.  It turned out that 'i' was used in
the subsequent loop in "j = i;". The fix just became too complex and I
didn't think it was worth the risk of breaking something just to get
rid of the showed 'i'.

David

Attachment

pgsql-hackers by date:

Previous
From: David Rowley
Date:
Subject: Re: Tracking last scan time
Next
From: Justin Pryzby
Date:
Subject: Re: shadow variables - pg15 edition