Hi, On 2019-07-17 12:04:32 +0900, Michael Paquier wrote: > On Tue, Jul 16, 2019 at 01:18:38PM -0700, Andres Freund wrote: > > I'd probably also just use the implementation we have for signed > > integers (minus the relevant negation and overflow checks, obviously) - > > it's a lot faster, and I think there's value in keeping the > > implementations in sync. > > You mean that it is much faster than the set of wrappers for strtol > than we have? Is that because we don't care about the base?
Yes: https://www.postgresql.org/message-id/20171208214437.qgn6zdltyq5hmjpk%40alap3.anarazel.de Not caring about the base is one significant part, that removes a fair bit of branches and more importantly allows the compiler to replace divisions with much faster code (glibc tries to avoid the division too, with lookup tables, but that's still expensive). Additionally there's also some locale awareness in strtoll etc that we don't need. It's also plainly not that well implemented at least in glibc and musl. Having an implementation that reliably works the same across all platforms is also advantageous. Greetings, Andres Freund