Re: Improve performance of pg_strtointNN functions
От | Dean Rasheed |
---|---|
Тема | Re: Improve performance of pg_strtointNN functions |
Дата | |
Msg-id | CAEZATCVEtwfhdm-K-etZYFB0=qsR0nT6qXta_W+GQx4RYph1dg@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Improve performance of pg_strtointNN functions (David Rowley <dgrowleyml@gmail.com>) |
Ответы |
Re: Improve performance of pg_strtointNN functions
|
Список | pgsql-hackers |
On Sun, 4 Dec 2022 at 03:19, David Rowley <dgrowleyml@gmail.com> wrote: > > Pushed with some small adjustments. > Ah, I see that you changed the overflow test, and I realise that I forgot to answer your question about why I wrote that as 1 - INT_MIN / 10 over on the other thread. The reason is that we need to detect whether tmp * base will exceed -INT_MIN, not INT_MAX, since we're accumulating the absolute value of a signed integer. So the right test is tmp >= 1 - INT_MIN / base or equivalently tmp > -(INT_MIN / base) I used the first form, because it didn't require extra parentheses, but that doesn't really matter. The point is that, in general, that's not the same as tmp > INT_MAX / base though it happens to be the same for base = 10, because INT_MIN and INT_MAX aren't divisible by 10. It will break when base is a power of 2 though, so although it's not broken now, it's morally wrong, and it risks breaking when Peter commits his patch. Regards, Dean
В списке pgsql-hackers по дате отправления: