aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/common/printsimple.c
diff options
context:
space:
mode:
authorDavid Rowley <drowley@postgresql.org>2020-06-13 12:32:00 +1200
committerDavid Rowley <drowley@postgresql.org>2020-06-13 12:32:00 +1200
commitdad75eb4a8d5835ecc795d7a7978e7702e4d5912 (patch)
tree8d0f2778f3c6f60e1343b585818d408d18881f14 /src/backend/access/common/printsimple.c
parent9a7fccd9eac85726ced3f3794a743eeab447f334 (diff)
downloadpostgresql-dad75eb4a8d5835ecc795d7a7978e7702e4d5912.tar.gz
postgresql-dad75eb4a8d5835ecc795d7a7978e7702e4d5912.zip
Have pg_itoa, pg_ltoa and pg_lltoa return the length of the string
Core by no means makes excessive use of these functions, but quite a large number of those usages do require the caller to call strlen() on the returned string. This is quite wasteful since these functions do already have a good idea of the length of the string, so we might as well just have them return that. Reviewed-by: Andrew Gierth Discussion: https://postgr.es/m/CAApHDvrm2A5x2uHYxsqriO2cUaGcFvND%2BksC9e7Tjep0t2RK_A%40mail.gmail.com
Diffstat (limited to 'src/backend/access/common/printsimple.c')
-rw-r--r--src/backend/access/common/printsimple.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/backend/access/common/printsimple.c b/src/backend/access/common/printsimple.c
index 0f0b54bdae3..df27700df92 100644
--- a/src/backend/access/common/printsimple.c
+++ b/src/backend/access/common/printsimple.c
@@ -103,9 +103,10 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
{
int32 num = DatumGetInt32(value);
char str[12]; /* sign, 10 digits and '\0' */
+ int len;
- pg_ltoa(num, str);
- pq_sendcountedtext(&buf, str, strlen(str), false);
+ len = pg_ltoa(num, str);
+ pq_sendcountedtext(&buf, str, len, false);
}
break;
@@ -113,9 +114,10 @@ printsimple(TupleTableSlot *slot, DestReceiver *self)
{
int64 num = DatumGetInt64(value);
char str[MAXINT8LEN + 1];
+ int len;
- pg_lltoa(num, str);
- pq_sendcountedtext(&buf, str, strlen(str), false);
+ len = pg_lltoa(num, str);
+ pq_sendcountedtext(&buf, str, len, false);
}
break;