Re: Greatest Common Divisor

Поиск
Список
Период
Сортировка
От Vik Fearing
Тема Re: Greatest Common Divisor
Дата
Msg-id 32b8af34-8f87-c30f-5555-2325bd140a59@2ndquadrant.com
обсуждение исходный текст
Ответ на Re: Greatest Common Divisor  (Fabien COELHO <coelho@cri.ensmp.fr>)
Ответы Re: Greatest Common Divisor
Список pgsql-hackers
On 03/01/2020 20:14, Fabien COELHO wrote:
>
> Bonsoir Vik,
>
>  +int4gcd_internal(int32 arg1, int32 arg2)
>  +{
>  +       int32   swap;
>  +
>  +       /*
>  +        * Put the greater value in arg1.
>  +        * This would happen automatically in the loop below, but
> avoids  an
>  +        * expensive modulo simulation on some architectures.
>  +        */
>  +       if (arg1 < arg2)
>  +       {
>  +               swap = arg1;
>  +               arg1 = arg2;
>  +               arg2 = swap;
>  +       }
>
>
> The point of swapping is to a void possibly expensive modulo, but this
> should be done on absolute values, otherwise it may not achieve its
> purpose as stated by the comment?


Here is an updated patch fixing that.

-- 

Vik Fearing


Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: pgsql: Add basic TAP tests for psql's tab-completion logic.
Следующее
От: Peter Geoghegan
Дата:
Сообщение: Re: pgsql: Add basic TAP tests for psql's tab-completion logic.