Tidy-up some appendStringInfo*() usages

Make a few newish calls to appendStringInfo() which have no special
formatting use appendStringInfoString() instead.  Also, adjust usages of
appendStringInfoString() which only append a string containing a single
character to make use of appendStringInfoChar() instead.

This makes the code marginally faster, but primarily this change is so
we use the StringInfo type as it was intended to be used.

Discussion: https://postgr.es/m/CAApHDvpXKQmL+r=VDNS98upqhr9yGBhv2Jw3GBFFk_wKHcB39A@mail.gmail.com
This commit is contained in:
David Rowley 2023-10-03 17:09:52 +13:00
parent 6b18b3fe2c
commit 2075ba9dc9
7 changed files with 11 additions and 11 deletions
src
backend
test/regress

@ -47,7 +47,7 @@ infobits_desc(StringInfo buf, uint8 infobits, const char *keyname)
buf->data[buf->len] = '\0';
}
appendStringInfoString(buf, "]");
appendStringInfoChar(buf, ']');
}
static void
@ -68,7 +68,7 @@ truncate_flags_desc(StringInfo buf, uint8 flags)
buf->data[buf->len] = '\0';
}
appendStringInfoString(buf, "]");
appendStringInfoChar(buf, ']');
}
static void
@ -88,7 +88,7 @@ plan_elem_desc(StringInfo buf, void *plan, void *data)
*offsets += new_plan->ntuples;
appendStringInfo(buf, " }");
appendStringInfoString(buf, " }");
}
void

@ -248,5 +248,5 @@ delvacuum_desc(StringInfo buf, char *block_data,
((char *) updates + SizeOfBtreeUpdate +
updates->ndeletedtids * sizeof(uint16));
}
appendStringInfoString(buf, "]");
appendStringInfoChar(buf, ']');
}

@ -37,7 +37,7 @@ array_desc(StringInfo buf, void *array, size_t elem_size, int count,
if (i < count - 1)
appendStringInfoString(buf, ", ");
}
appendStringInfoString(buf, "]");
appendStringInfoChar(buf, ']');
}
void

@ -58,7 +58,7 @@ build_backup_content(BackupState *state, bool ishistoryfile)
appendStringInfo(result, "CHECKPOINT LOCATION: %X/%X\n",
LSN_FORMAT_ARGS(state->checkpointloc));
appendStringInfo(result, "BACKUP METHOD: streamed\n");
appendStringInfoString(result, "BACKUP METHOD: streamed\n");
appendStringInfo(result, "BACKUP FROM: %s\n",
state->started_in_recovery ? "standby" : "primary");
appendStringInfo(result, "START TIME: %s\n", startstrbuf);

@ -1282,7 +1282,7 @@ ReportSlotInvalidation(ReplicationSlotInvalidationCause cause,
break;
case RS_INVAL_WAL_LEVEL:
appendStringInfo(&err_detail, _("Logical decoding on standby requires wal_level >= logical on the primary server."));
appendStringInfoString(&err_detail, _("Logical decoding on standby requires wal_level >= logical on the primary server."));
break;
case RS_INVAL_NONE:
pg_unreachable();

@ -10395,7 +10395,7 @@ get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
case F_IS_NORMALIZED:
/* IS xxx NORMALIZED */
appendStringInfoString(buf, "(");
appendStringInfoChar(buf, '(');
get_rule_expr_paren((Node *) linitial(expr->args), context, false,
(Node *) expr);
appendStringInfoString(buf, " IS");
@ -10884,7 +10884,7 @@ get_json_constructor(JsonConstructorExpr *ctor, deparse_context *context,
}
get_json_constructor_options(ctor, buf);
appendStringInfo(buf, ")");
appendStringInfoChar(buf, ')');
}
/*

@ -2339,9 +2339,9 @@ regression_main(int argc, char *argv[],
bindir ? "/" : "",
temp_instance);
if (debug)
appendStringInfo(&cmd, " --debug");
appendStringInfoString(&cmd, " --debug");
if (nolocale)
appendStringInfo(&cmd, " --no-locale");
appendStringInfoString(&cmd, " --no-locale");
appendStringInfo(&cmd, " > \"%s/log/initdb.log\" 2>&1", outputdir);
fflush(NULL);
if (system(cmd.data))