From 86eaf208ea048936df6be77276a246d3f92e9620 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Sun, 22 Jul 2018 14:58:01 -0700 Subject: Hand code string to integer conversion for performance. As benchmarks show, using libc's string-to-integer conversion is pretty slow. At least part of the reason for that is that strtol[l] have to be more generic than what largely is required inside pg. This patch considerably speeds up int2/int4 input (int8 already was already using hand-rolled code). Most of the existing pg_atoi callers have been converted. But as one requires pg_atoi's custom delimiter functionality, and as it seems likely that there's external pg_atoi users, it seems sensible to just keep pg_atoi around. Author: Andres Freund Reviewed-By: Robert Haas Discussion: https://postgr.es/m/20171208214437.qgn6zdltyq5hmjpk@alap3.anarazel.de --- src/backend/utils/adt/int8.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/backend/utils/adt/int8.c') diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 49f32a8b3dd..3c595e800a4 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -101,6 +101,7 @@ scanint8(const char *str, bool errorOK, int64 *result) if (!neg) { + /* could fail if input is most negative number */ if (unlikely(tmp == PG_INT64_MIN)) goto out_of_range; tmp = -tmp; -- cgit v1.2.3