Re: Minor code de-duplication in fe-connect.c

From: Daniel Gustafsson <daniel(at)yesql(dot)se>
To: Gurjeet Singh <gurjeet(at)singh(dot)im>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Minor code de-duplication in fe-connect.c
Date: 2023-04-21 12:24:53
Message-ID: BF683DB4-96FB-48CE-AA58-EC76CDE03445@yesql.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On 21 Apr 2023, at 07:29, Gurjeet Singh <gurjeet(at)singh(dot)im> wrote:
>
> Commit [1] implements Fisher-Yates shuffling algorithm to shuffle
> connection addresses, in two places.
>
> The attached patch moves the duplicated code to a function, and calls
> it in those 2 places.

The reason I left it like this when reviewing and committing is that I think it
makes for more readable code. The amount of lines saved is pretty small, and
"shuffle" isn't an exact term so by reading the code it isn't immediate clear
what such a function would do. By having the shuffle algorithm where it's used
it's clear what the code does and what the outcome is. If others disagree I
can go ahead and refactor of course, but I personally would not deem it a net
win in code quality.

--
Daniel Gustafsson

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-04-21 12:51:08 Re: Non-superuser subscription owners
Previous Message Anton Voloshin 2023-04-21 12:20:54 Re: duplicate function declaration in multirangetypes_selfuncs.c