diff options
author | David Rowley <drowley@postgresql.org> | 2019-07-23 00:14:11 +1200 |
---|---|---|
committer | David Rowley <drowley@postgresql.org> | 2019-07-23 00:14:11 +1200 |
commit | 1e6a759838f7c104f3cd1fe6981a98780da4131b (patch) | |
tree | 47047d8991d0918b531fe71f38b637dc086c9ffa /src/backend/utils/adt/xml.c | |
parent | 19781729f789f3c6b2540e02b96f8aa500460322 (diff) | |
download | postgresql-1e6a759838f7c104f3cd1fe6981a98780da4131b.tar.gz postgresql-1e6a759838f7c104f3cd1fe6981a98780da4131b.zip |
Use appendBinaryStringInfo in more places where the length is known
When we already know the length that we're going to append, then it
makes sense to use appendBinaryStringInfo instead of
appendStringInfoString so that the append can be performed with a simple
memcpy() using a known length rather than having to first perform a
strlen() call to obtain the length.
Discussion: https://postgr.es/m/CAKJS1f8+FRAM1s5+mAa3isajeEoAaicJ=4e0WzrH3tAusbbiMQ@mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/xml.c')
-rw-r--r-- | src/backend/utils/adt/xml.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index d43c3055f3a..5e629d29ea8 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -559,7 +559,7 @@ xmlconcat(List *args) 0, global_standalone); - appendStringInfoString(&buf2, buf.data); + appendBinaryStringInfo(&buf2, buf.data, buf.len); buf = buf2; } @@ -1879,7 +1879,8 @@ xml_errorHandler(void *data, xmlErrorPtr error) if (xmlerrcxt->strictness == PG_XML_STRICTNESS_LEGACY) { appendStringInfoLineSeparator(&xmlerrcxt->err_buf); - appendStringInfoString(&xmlerrcxt->err_buf, errorBuf->data); + appendBinaryStringInfo(&xmlerrcxt->err_buf, errorBuf->data, + errorBuf->len); pfree(errorBuf->data); pfree(errorBuf); @@ -1897,7 +1898,8 @@ xml_errorHandler(void *data, xmlErrorPtr error) if (level >= XML_ERR_ERROR) { appendStringInfoLineSeparator(&xmlerrcxt->err_buf); - appendStringInfoString(&xmlerrcxt->err_buf, errorBuf->data); + appendBinaryStringInfo(&xmlerrcxt->err_buf, errorBuf->data, + errorBuf->len); xmlerrcxt->err_occurred = true; } @@ -2874,7 +2876,7 @@ schema_to_xml_internal(Oid nspid, const char *xmlschema, bool nulls, subres = table_to_xml_internal(relid, NULL, nulls, tableforest, targetns, false); - appendStringInfoString(result, subres->data); + appendBinaryStringInfo(result, subres->data, subres->len); appendStringInfoChar(result, '\n'); } @@ -3049,7 +3051,7 @@ database_to_xml_internal(const char *xmlschema, bool nulls, subres = schema_to_xml_internal(nspid, NULL, nulls, tableforest, targetns, false); - appendStringInfoString(result, subres->data); + appendBinaryStringInfo(result, subres->data, subres->len); appendStringInfoChar(result, '\n'); } |