From 4fc115b2e981f8c63165ca86a23215380a3fda66 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Fri, 19 Nov 2010 22:13:11 -0500 Subject: Speed up conversion of signed integers to C strings. A hand-coded implementation turns out to be much faster than calling printf(). In passing, add a few more regresion tests. Andres Freund, with assorted, mostly cosmetic changes. --- src/backend/utils/adt/int8.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (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 894110d7a2..91133f7741 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -20,6 +20,7 @@ #include "funcapi.h" #include "libpq/pqformat.h" #include "utils/int8.h" +#include "utils/builtins.h" #define MAXINT8LEN 25 @@ -157,13 +158,10 @@ Datum int8out(PG_FUNCTION_ARGS) { int64 val = PG_GETARG_INT64(0); - char *result; - int len; char buf[MAXINT8LEN + 1]; + char *result; - if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, val)) < 0) - elog(ERROR, "could not format int8"); - + pg_lltoa(val, buf); result = pstrdup(buf); PG_RETURN_CSTRING(result); } -- cgit v1.2.1