From: | Vik Fearing <vik(dot)fearing(at)2ndquadrant(dot)com> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Stephen Frost <sfrost(at)snowman(dot)net>, Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Chapman Flack <chap(at)anastigmatix(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Greatest Common Divisor |
Date: | 2020-01-04 02:32:34 |
Message-ID: | 32b8af34-8f87-c30f-5555-2325bd140a59@2ndquadrant.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
Attachment | Content-Type | Size |
---|---|---|
gcd.0005.patch | text/x-patch | 23.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Geoghegan | 2020-01-04 02:37:25 | Re: pgsql: Add basic TAP tests for psql's tab-completion logic. |
Previous Message | Tom Lane | 2020-01-04 02:16:42 | Re: pgsql: Add basic TAP tests for psql's tab-completion logic. |