diff options
author | David Rowley <drowley@postgresql.org> | 2020-06-13 12:32:00 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2020-06-13 12:32:00 +1200 |
commit | dad75eb4a8d5835ecc795d7a7978e7702e4d5912 (patch) | |
tree | 8d0f2778f3c6f60e1343b585818d408d18881f14 /src/backend/utils/adt/int.c | |
parent | 9a7fccd9eac85726ced3f3794a743eeab447f334 (diff) | |
download | postgresql-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/utils/adt/int.c')
-rw-r--r-- | src/backend/utils/adt/int.c | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index 63c59c56b3f..418c13e1b4c 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -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); |