Re: Remove dependence on integer wrapping - Mailing list pgsql-hackers

From Joseph Koshakow
Subject Re: Remove dependence on integer wrapping
Date
Msg-id CAAvxfHc2Smk92cJX4aUju1AdW_RpNN8csEj5rvf29b-YFHRmfQ@mail.gmail.com
Whole thread Raw
In response to Re: Remove dependence on integer wrapping  (Nathan Bossart <nathandbossart@gmail.com>)
List pgsql-hackers
Thanks for the improvements Nathan. The current iteration LGTM, just a
single comment on `pg_abs_s64`

> +static inline uint64
> +pg_abs_s64(int64 a)
> +{
> +     if (unlikely(a == PG_INT64_MIN))
> +         return (uint64) PG_INT64_MAX + 1;
> +     if (a < 0)
> +         return -a;
> +     return a;
> +}

Since we know that a does not equal PG_INT64_MIN, could we shorten the
last three lines and do the following?


    static inline uint64
    pg_abs_s64(int64 a)
    {
        if (unlikely(a == PG_INT64_MIN))
          return (uint64) PG_INT64_MAX + 1;
        return i64_abs(a);
    }

Thanks,
Joseph Koshakow

pgsql-hackers by date:

Previous
From: "Joel Jacobson"
Date:
Subject: Re: [PATCH] Add get_bytes() and set_bytes() functions
Next
From: Jelte Fennema-Nio
Date:
Subject: Re: libpq: Fix lots of discrepancies in PQtrace