Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 7b2cf17

Browse files
author
Neil Conway
committed
Micro-opt: replace calls like
appendStringInfo(buf, "%s", str); with appendStringInfoString(buf, str); as the latter form is slightly faster.
1 parent d4fd7d8 commit 7b2cf17

File tree

6 files changed

+31
-33
lines changed

6 files changed

+31
-33
lines changed

src/backend/commands/explain.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.118 2003/11/29 19:51:47 pgsql Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.119 2004/01/31 05:09:40 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1002,7 +1002,7 @@ show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols,
10021002
/* And add to str */
10031003
if (keyno > 0)
10041004
appendStringInfo(str, ", ");
1005-
appendStringInfo(str, "%s", exprstr);
1005+
appendStringInfoString(str, exprstr);
10061006
}
10071007

10081008
appendStringInfo(str, "\n");

src/backend/nodes/outfuncs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.231 2004/01/22 00:34:31 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.232 2004/01/31 05:09:40 neilc Exp $
1212
*
1313
* NOTES
1414
* Every node type that can appear in stored rules' parsetrees *must*
@@ -1427,7 +1427,7 @@ _outValue(StringInfo str, Value *value)
14271427
* We assume the value is a valid numeric literal and so does
14281428
* not need quoting.
14291429
*/
1430-
appendStringInfo(str, "%s", value->val.str);
1430+
appendStringInfoString(str, value->val.str);
14311431
break;
14321432
case T_String:
14331433
appendStringInfoChar(str, '"');
@@ -1436,7 +1436,7 @@ _outValue(StringInfo str, Value *value)
14361436
break;
14371437
case T_BitString:
14381438
/* internal representation already has leading 'b' */
1439-
appendStringInfo(str, "%s", value->val.str);
1439+
appendStringInfoString(str, value->val.str);
14401440
break;
14411441
default:
14421442
elog(ERROR, "unrecognized node type: %d", (int) value->type);

src/backend/utils/adt/regproc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.85 2003/11/29 19:51:59 pgsql Exp $
16+
* $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.86 2004/01/31 05:09:40 neilc Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -340,7 +340,7 @@ format_procedure(Oid procedure_oid)
340340

341341
if (i > 0)
342342
appendStringInfoChar(&buf, ',');
343-
appendStringInfo(&buf, "%s", format_type_be(thisargtype));
343+
appendStringInfoString(&buf, format_type_be(thisargtype));
344344
}
345345
appendStringInfoChar(&buf, ')');
346346

src/backend/utils/adt/ruleutils.c

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* back to source text
44
*
55
* IDENTIFICATION
6-
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.161 2003/12/28 21:57:37 tgl Exp $
6+
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.162 2004/01/31 05:09:40 neilc Exp $
77
*
88
* This software is copyrighted by Jan Wieck - Hamburg.
99
*
@@ -752,7 +752,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags)
752752

753753
attname = get_relid_attribute_name(indrelid, attnum);
754754
if (!colno || colno == keyno + 1)
755-
appendStringInfo(&buf, "%s", quote_identifier(attname));
755+
appendStringInfoString(&buf, quote_identifier(attname));
756756
keycoltype = get_atttype(indrelid, attnum);
757757
}
758758
else
@@ -772,7 +772,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags)
772772
/* Need parens if it's not a bare function call */
773773
if (indexkey && IsA(indexkey, FuncExpr) &&
774774
((FuncExpr *) indexkey)->funcformat == COERCE_EXPLICIT_CALL)
775-
appendStringInfo(&buf, "%s", str);
775+
appendStringInfoString(&buf, str);
776776
else
777777
appendStringInfo(&buf, "(%s)", str);
778778
}
@@ -947,7 +947,7 @@ pg_get_constraintdef_worker(Oid constraintId, int prettyFlags)
947947
string = ""; /* keep compiler quiet */
948948
break;
949949
}
950-
appendStringInfo(&buf, "%s", string);
950+
appendStringInfoString(&buf, string);
951951

952952
/* Add ON UPDATE and ON DELETE clauses, if needed */
953953
switch (conForm->confupdtype)
@@ -1126,11 +1126,9 @@ decompile_column_index_array(Datum column_index_array, Oid relId,
11261126
colName = get_relid_attribute_name(relId, DatumGetInt16(keys[j]));
11271127

11281128
if (j == 0)
1129-
appendStringInfo(buf, "%s",
1130-
quote_identifier(colName));
1129+
appendStringInfoString(buf, quote_identifier(colName));
11311130
else
1132-
appendStringInfo(buf, ", %s",
1133-
quote_identifier(colName));
1131+
appendStringInfo(buf, ", %s", quote_identifier(colName));
11341132
}
11351133
}
11361134

@@ -2134,9 +2132,9 @@ get_insert_query_def(Query *query, deparse_context *context)
21342132

21352133
appendStringInfo(buf, sep);
21362134
sep = ", ";
2137-
appendStringInfo(buf, "%s",
2138-
quote_identifier(get_relid_attribute_name(rte->relid,
2139-
tle->resdom->resno)));
2135+
appendStringInfoString(buf,
2136+
quote_identifier(get_relid_attribute_name(rte->relid,
2137+
tle->resdom->resno)));
21402138
}
21412139
appendStringInfo(buf, ") ");
21422140

@@ -2753,7 +2751,7 @@ get_rule_expr(Node *node, deparse_context *context,
27532751
quote_identifier(refname));
27542752
}
27552753
if (attname)
2756-
appendStringInfo(buf, "%s", quote_identifier(attname));
2754+
appendStringInfoString(buf, quote_identifier(attname));
27572755
else
27582756
appendStringInfo(buf, "*");
27592757
}
@@ -3763,8 +3761,8 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
37633761
{
37643762
if (col != rte->alias->colnames)
37653763
appendStringInfo(buf, ", ");
3766-
appendStringInfo(buf, "%s",
3767-
quote_identifier(strVal(lfirst(col))));
3764+
appendStringInfoString(buf,
3765+
quote_identifier(strVal(lfirst(col))));
37683766
}
37693767
appendStringInfoChar(buf, ')');
37703768
}
@@ -3902,8 +3900,8 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
39023900
{
39033901
if (col != j->using)
39043902
appendStringInfo(buf, ", ");
3905-
appendStringInfo(buf, "%s",
3906-
quote_identifier(strVal(lfirst(col))));
3903+
appendStringInfoString(buf,
3904+
quote_identifier(strVal(lfirst(col))));
39073905
}
39083906
appendStringInfoChar(buf, ')');
39093907
}
@@ -3934,7 +3932,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
39343932
{
39353933
if (col != j->alias->colnames)
39363934
appendStringInfo(buf, ", ");
3937-
appendStringInfo(buf, "%s",
3935+
appendStringInfoString(buf,
39383936
quote_identifier(strVal(lfirst(col))));
39393937
}
39403938
appendStringInfoChar(buf, ')');
@@ -4164,7 +4162,7 @@ quote_qualified_identifier(const char *namespace,
41644162
initStringInfo(&buf);
41654163
if (namespace)
41664164
appendStringInfo(&buf, "%s.", quote_identifier(namespace));
4167-
appendStringInfo(&buf, "%s", quote_identifier(ident));
4165+
appendStringInfoString(&buf, quote_identifier(ident));
41684166
return buf.data;
41694167
}
41704168

@@ -4316,7 +4314,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
43164314
appendStringInfo(&buf, "OPERATOR(%s.", quote_identifier(nspname));
43174315
}
43184316

4319-
appendStringInfo(&buf, "%s", oprname);
4317+
appendStringInfoString(&buf, oprname);
43204318

43214319
if (nspname)
43224320
appendStringInfoChar(&buf, ')');
@@ -4338,7 +4336,7 @@ print_operator_name(StringInfo buf, List *opname)
43384336
int nnames = length(opname);
43394337

43404338
if (nnames == 1)
4341-
appendStringInfo(buf, "%s", strVal(lfirst(opname)));
4339+
appendStringInfoString(buf, strVal(lfirst(opname)));
43424340
else
43434341
{
43444342
appendStringInfo(buf, "OPERATOR(");

src/backend/utils/adt/varlena.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.110 2004/01/31 00:45:21 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.111 2004/01/31 05:09:40 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -2232,7 +2232,7 @@ array_to_text(PG_FUNCTION_ARGS)
22322232
if (i > 0)
22332233
appendStringInfo(result_str, "%s%s", fldsep, value);
22342234
else
2235-
appendStringInfo(result_str, "%s", value);
2235+
appendStringInfoString(result_str, value);
22362236

22372237
p = att_addlength(p, typlen, PointerGetDatum(p));
22382238
p = (char *) att_align(p, typalign);

src/backend/utils/misc/guc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.181 2004/01/26 22:35:32 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.182 2004/01/31 05:09:41 neilc Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -3259,7 +3259,7 @@ flatten_set_variable_args(const char *name, List *args)
32593259
break;
32603260
case T_Float:
32613261
/* represented as a string, so just copy it */
3262-
appendStringInfo(&buf, "%s", strVal(&arg->val));
3262+
appendStringInfoString(&buf, strVal(&arg->val));
32633263
break;
32643264
case T_String:
32653265
val = strVal(&arg->val);
@@ -3293,9 +3293,9 @@ flatten_set_variable_args(const char *name, List *args)
32933293
* mode, quote it if it's not a vanilla identifier.
32943294
*/
32953295
if (flags & GUC_LIST_QUOTE)
3296-
appendStringInfo(&buf, "%s", quote_identifier(val));
3296+
appendStringInfoString(&buf, quote_identifier(val));
32973297
else
3298-
appendStringInfo(&buf, "%s", val);
3298+
appendStringInfoString(&buf, val);
32993299
}
33003300
break;
33013301
default:

0 commit comments

Comments
 (0)