1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

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
This commit is contained in:
David Rowley
2020-06-13 12:32:00 +12:00
parent 9a7fccd9ea
commit dad75eb4a8
5 changed files with 38 additions and 25 deletions

View File

@@ -191,9 +191,7 @@ int2vectorout(PG_FUNCTION_ARGS)
{
if (num != 0)
*rp++ = ' ';
pg_itoa(int2Array->values[num], rp);
while (*++rp != '\0')
;
rp += pg_itoa(int2Array->values[num], rp);
}
*rp = '\0';
PG_RETURN_CSTRING(result);