mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
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.
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user