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

Поиск
Список
Период
Сортировка
От Daniel Gustafsson
Тема Re: Minor code de-duplication in fe-connect.c
Дата
Msg-id BF683DB4-96FB-48CE-AA58-EC76CDE03445@yesql.se
обсуждение исходный текст
Ответ на Minor code de-duplication in fe-connect.c  (Gurjeet Singh <gurjeet@singh.im>)
Ответы Re: Minor code de-duplication in fe-connect.c  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
> On 21 Apr 2023, at 07:29, Gurjeet Singh <gurjeet@singh.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




В списке pgsql-hackers по дате отправления:

Предыдущее
От: Anton Voloshin
Дата:
Сообщение: Re: duplicate function declaration in multirangetypes_selfuncs.c
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Non-superuser subscription owners