From cacbdd78106526d7c4f11f90b538f96ba8696fb0 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 31 Oct 2013 10:55:59 -0400 Subject: Use appendStringInfoString instead of appendStringInfo where possible. This shaves a few cycles, and generally seems like good programming practice. David Rowley --- src/backend/utils/adt/xml.c | 66 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 34 deletions(-) (limited to 'src/backend/utils/adt/xml.c') diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 25ab79b1979..bbe08d0f5b9 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -442,9 +442,9 @@ xmlcomment(PG_FUNCTION_ARGS) errmsg("invalid XML comment"))); initStringInfo(&buf); - appendStringInfo(&buf, ""); + appendStringInfoString(&buf, "-->"); PG_RETURN_XML_P(stringinfo_to_xmltype(&buf)); #else @@ -1852,19 +1852,19 @@ map_sql_identifier_to_xml_name(char *ident, bool fully_escaped, for (p = ident; *p; p += pg_mblen(p)) { if (*p == ':' && (p == ident || fully_escaped)) - appendStringInfo(&buf, "_x003A_"); + appendStringInfoString(&buf, "_x003A_"); else if (*p == '_' && *(p + 1) == 'x') - appendStringInfo(&buf, "_x005F_"); + appendStringInfoString(&buf, "_x005F_"); else if (fully_escaped && p == ident && pg_strncasecmp(p, "xml", 3) == 0) { if (*p == 'x') - appendStringInfo(&buf, "_x0078_"); + appendStringInfoString(&buf, "_x0078_"); else - appendStringInfo(&buf, "_x0058_"); + appendStringInfoString(&buf, "_x0058_"); } else if (escape_period && *p == '.') - appendStringInfo(&buf, "_x002E_"); + appendStringInfoString(&buf, "_x002E_"); else { pg_wchar u = sqlchar_to_unicode(p); @@ -2438,9 +2438,9 @@ xmldata_root_element_start(StringInfo result, const char *eltname, if (strlen(targetns) > 0) appendStringInfo(result, " xsi:schemaLocation=\"%s #\"", targetns); else - appendStringInfo(result, " xsi:noNamespaceSchemaLocation=\"#\""); + appendStringInfoString(result, " xsi:noNamespaceSchemaLocation=\"#\""); } - appendStringInfo(result, ">\n"); + appendStringInfoString(result, ">\n"); } @@ -2945,7 +2945,7 @@ map_multipart_sql_identifier_to_xml_name(char *a, char *b, char *c, char *d) initStringInfo(&result); if (a) - appendStringInfo(&result, "%s", + appendStringInfoString(&result, map_sql_identifier_to_xml_name(a, true, true)); if (b) appendStringInfo(&result, ".%s", @@ -3212,71 +3212,71 @@ map_sql_type_to_xml_name(Oid typeoid, int typmod) { case BPCHAROID: if (typmod == -1) - appendStringInfo(&result, "CHAR"); + appendStringInfoString(&result, "CHAR"); else appendStringInfo(&result, "CHAR_%d", typmod - VARHDRSZ); break; case VARCHAROID: if (typmod == -1) - appendStringInfo(&result, "VARCHAR"); + appendStringInfoString(&result, "VARCHAR"); else appendStringInfo(&result, "VARCHAR_%d", typmod - VARHDRSZ); break; case NUMERICOID: if (typmod == -1) - appendStringInfo(&result, "NUMERIC"); + appendStringInfoString(&result, "NUMERIC"); else appendStringInfo(&result, "NUMERIC_%d_%d", ((typmod - VARHDRSZ) >> 16) & 0xffff, (typmod - VARHDRSZ) & 0xffff); break; case INT4OID: - appendStringInfo(&result, "INTEGER"); + appendStringInfoString(&result, "INTEGER"); break; case INT2OID: - appendStringInfo(&result, "SMALLINT"); + appendStringInfoString(&result, "SMALLINT"); break; case INT8OID: - appendStringInfo(&result, "BIGINT"); + appendStringInfoString(&result, "BIGINT"); break; case FLOAT4OID: - appendStringInfo(&result, "REAL"); + appendStringInfoString(&result, "REAL"); break; case FLOAT8OID: - appendStringInfo(&result, "DOUBLE"); + appendStringInfoString(&result, "DOUBLE"); break; case BOOLOID: - appendStringInfo(&result, "BOOLEAN"); + appendStringInfoString(&result, "BOOLEAN"); break; case TIMEOID: if (typmod == -1) - appendStringInfo(&result, "TIME"); + appendStringInfoString(&result, "TIME"); else appendStringInfo(&result, "TIME_%d", typmod); break; case TIMETZOID: if (typmod == -1) - appendStringInfo(&result, "TIME_WTZ"); + appendStringInfoString(&result, "TIME_WTZ"); else appendStringInfo(&result, "TIME_WTZ_%d", typmod); break; case TIMESTAMPOID: if (typmod == -1) - appendStringInfo(&result, "TIMESTAMP"); + appendStringInfoString(&result, "TIMESTAMP"); else appendStringInfo(&result, "TIMESTAMP_%d", typmod); break; case TIMESTAMPTZOID: if (typmod == -1) - appendStringInfo(&result, "TIMESTAMP_WTZ"); + appendStringInfoString(&result, "TIMESTAMP_WTZ"); else appendStringInfo(&result, "TIMESTAMP_WTZ_%d", typmod); break; case DATEOID: - appendStringInfo(&result, "DATE"); + appendStringInfoString(&result, "DATE"); break; case XMLOID: - appendStringInfo(&result, "XML"); + appendStringInfoString(&result, "XML"); break; default: { @@ -3370,7 +3370,7 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod) if (typeoid == XMLOID) { - appendStringInfo(&result, + appendStringInfoString(&result, "\n" " \n" " \n" @@ -3393,8 +3393,7 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod) appendStringInfo(&result, " \n", typmod - VARHDRSZ); - appendStringInfo(&result, - " \n"); + appendStringInfoString(&result, " \n"); break; case BYTEAOID: @@ -3444,17 +3443,17 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod) break; case FLOAT4OID: - appendStringInfo(&result, + appendStringInfoString(&result, " \n"); break; case FLOAT8OID: - appendStringInfo(&result, + appendStringInfoString(&result, " \n"); break; case BOOLOID: - appendStringInfo(&result, + appendStringInfoString(&result, " \n"); break; @@ -3505,7 +3504,7 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod) } case DATEOID: - appendStringInfo(&result, + appendStringInfoString(&result, " \n" " \n" " \n"); @@ -3525,8 +3524,7 @@ map_sql_type_to_xmlschema_type(Oid typeoid, int typmod) } break; } - appendStringInfo(&result, - "\n"); + appendStringInfoString(&result, "\n"); } return result.data; -- cgit v1.2.3