Micro-opt: replace calls like
authorNeil Conway
Sat, 31 Jan 2004 05:09:41 +0000 (05:09 +0000)
committerNeil Conway
Sat, 31 Jan 2004 05:09:41 +0000 (05:09 +0000)
    appendStringInfo(buf, "%s", str);
with
    appendStringInfoString(buf, str);
as the latter form is slightly faster.

src/backend/commands/explain.c
src/backend/nodes/outfuncs.c
src/backend/utils/adt/regproc.c
src/backend/utils/adt/ruleutils.c
src/backend/utils/adt/varlena.c
src/backend/utils/misc/guc.c

index 940c39f83a4b38e7767f0e0eafcc05b6b66ee668..3c134a5c16606faf6436bb0532bfd61a3818b3de 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1994-5, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.118 2003/11/29 19:51:47 pgsql Exp $
+ *   $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.119 2004/01/31 05:09:40 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1002,7 +1002,7 @@ show_sort_keys(List *tlist, int nkeys, AttrNumber *keycols,
        /* And add to str */
        if (keyno > 0)
            appendStringInfo(str, ", ");
-       appendStringInfo(str, "%s", exprstr);
+       appendStringInfoString(str, exprstr);
    }
 
    appendStringInfo(str, "\n");
index b0ff9e3e3226fc0a66b89b328abd0083437ebb84..93afd868f8751a72ea5b89bf07f9515f9bffe58f 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.231 2004/01/22 00:34:31 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.232 2004/01/31 05:09:40 neilc Exp $
  *
  * NOTES
  *   Every node type that can appear in stored rules' parsetrees *must*
@@ -1427,7 +1427,7 @@ _outValue(StringInfo str, Value *value)
             * We assume the value is a valid numeric literal and so does
             * not need quoting.
             */
-           appendStringInfo(str, "%s", value->val.str);
+           appendStringInfoString(str, value->val.str);
            break;
        case T_String:
            appendStringInfoChar(str, '"');
@@ -1436,7 +1436,7 @@ _outValue(StringInfo str, Value *value)
            break;
        case T_BitString:
            /* internal representation already has leading 'b' */
-           appendStringInfo(str, "%s", value->val.str);
+           appendStringInfoString(str, value->val.str);
            break;
        default:
            elog(ERROR, "unrecognized node type: %d", (int) value->type);
index d11fd02ce4f6896e053a0e2626f32da00d84265a..40203161e7dd4fa3671f64c4af7d2bfea7d5c85a 100644 (file)
@@ -13,7 +13,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.85 2003/11/29 19:51:59 pgsql Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/regproc.c,v 1.86 2004/01/31 05:09:40 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -340,7 +340,7 @@ format_procedure(Oid procedure_oid)
 
            if (i > 0)
                appendStringInfoChar(&buf, ',');
-           appendStringInfo(&buf, "%s", format_type_be(thisargtype));
+           appendStringInfoString(&buf, format_type_be(thisargtype));
        }
        appendStringInfoChar(&buf, ')');
 
index f8937c7ea649cb6d11661fb1d95ddca20d27e067..7e1513796db032ba4c407e4ffebd406691226462 100644 (file)
@@ -3,7 +3,7 @@
  *             back to source text
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.161 2003/12/28 21:57:37 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.162 2004/01/31 05:09:40 neilc Exp $
  *
  *   This software is copyrighted by Jan Wieck - Hamburg.
  *
@@ -752,7 +752,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags)
 
            attname = get_relid_attribute_name(indrelid, attnum);
            if (!colno || colno == keyno + 1)
-               appendStringInfo(&buf, "%s", quote_identifier(attname));
+               appendStringInfoString(&buf, quote_identifier(attname));
            keycoltype = get_atttype(indrelid, attnum);
        }
        else
@@ -772,7 +772,7 @@ pg_get_indexdef_worker(Oid indexrelid, int colno, int prettyFlags)
                /* Need parens if it's not a bare function call */
                if (indexkey && IsA(indexkey, FuncExpr) &&
                    ((FuncExpr *) indexkey)->funcformat == COERCE_EXPLICIT_CALL)
-                   appendStringInfo(&buf, "%s", str);
+                   appendStringInfoString(&buf, str);
                else
                    appendStringInfo(&buf, "(%s)", str);
            }
@@ -947,7 +947,7 @@ pg_get_constraintdef_worker(Oid constraintId, int prettyFlags)
                        string = "";    /* keep compiler quiet */
                        break;
                }
-               appendStringInfo(&buf, "%s", string);
+               appendStringInfoString(&buf, string);
 
                /* Add ON UPDATE and ON DELETE clauses, if needed */
                switch (conForm->confupdtype)
@@ -1126,11 +1126,9 @@ decompile_column_index_array(Datum column_index_array, Oid relId,
        colName = get_relid_attribute_name(relId, DatumGetInt16(keys[j]));
 
        if (j == 0)
-           appendStringInfo(buf, "%s",
-                            quote_identifier(colName));
+           appendStringInfoString(buf, quote_identifier(colName));
        else
-           appendStringInfo(buf, ", %s",
-                            quote_identifier(colName));
+           appendStringInfo(buf, ", %s", quote_identifier(colName));
    }
 }
 
@@ -2134,9 +2132,9 @@ get_insert_query_def(Query *query, deparse_context *context)
 
        appendStringInfo(buf, sep);
        sep = ", ";
-       appendStringInfo(buf, "%s",
-                        quote_identifier(get_relid_attribute_name(rte->relid,
-                                                       tle->resdom->resno)));
+       appendStringInfoString(buf,
+                              quote_identifier(get_relid_attribute_name(rte->relid,
+                                                                        tle->resdom->resno)));
    }
    appendStringInfo(buf, ") ");
 
@@ -2753,7 +2751,7 @@ get_rule_expr(Node *node, deparse_context *context,
                                         quote_identifier(refname));
                }
                if (attname)
-                   appendStringInfo(buf, "%s", quote_identifier(attname));
+                   appendStringInfoString(buf, quote_identifier(attname));
                else
                    appendStringInfo(buf, "*");
            }
@@ -3763,8 +3761,8 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
                {
                    if (col != rte->alias->colnames)
                        appendStringInfo(buf, ", ");
-                   appendStringInfo(buf, "%s",
-                                 quote_identifier(strVal(lfirst(col))));
+                   appendStringInfoString(buf,
+                                          quote_identifier(strVal(lfirst(col))));
                }
                appendStringInfoChar(buf, ')');
            }
@@ -3902,8 +3900,8 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
                {
                    if (col != j->using)
                        appendStringInfo(buf, ", ");
-                   appendStringInfo(buf, "%s",
-                                 quote_identifier(strVal(lfirst(col))));
+                   appendStringInfoString(buf,
+                               quote_identifier(strVal(lfirst(col))));
                }
                appendStringInfoChar(buf, ')');
            }
@@ -3934,7 +3932,7 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
                {
                    if (col != j->alias->colnames)
                        appendStringInfo(buf, ", ");
-                   appendStringInfo(buf, "%s",
+                   appendStringInfoString(buf,
                                  quote_identifier(strVal(lfirst(col))));
                }
                appendStringInfoChar(buf, ')');
@@ -4164,7 +4162,7 @@ quote_qualified_identifier(const char *namespace,
    initStringInfo(&buf);
    if (namespace)
        appendStringInfo(&buf, "%s.", quote_identifier(namespace));
-   appendStringInfo(&buf, "%s", quote_identifier(ident));
+   appendStringInfoString(&buf, quote_identifier(ident));
    return buf.data;
 }
 
@@ -4316,7 +4314,7 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2)
        appendStringInfo(&buf, "OPERATOR(%s.", quote_identifier(nspname));
    }
 
-   appendStringInfo(&buf, "%s", oprname);
+   appendStringInfoString(&buf, oprname);
 
    if (nspname)
        appendStringInfoChar(&buf, ')');
@@ -4338,7 +4336,7 @@ print_operator_name(StringInfo buf, List *opname)
    int         nnames = length(opname);
 
    if (nnames == 1)
-       appendStringInfo(buf, "%s", strVal(lfirst(opname)));
+       appendStringInfoString(buf, strVal(lfirst(opname)));
    else
    {
        appendStringInfo(buf, "OPERATOR(");
index e3337fe7d8097df31d3767e751fadacdee98d1bd..3d96ce23ac5e5a74d590b7466656361ef2c42268 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.110 2004/01/31 00:45:21 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/varlena.c,v 1.111 2004/01/31 05:09:40 neilc Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -2232,7 +2232,7 @@ array_to_text(PG_FUNCTION_ARGS)
        if (i > 0)
            appendStringInfo(result_str, "%s%s", fldsep, value);
        else
-           appendStringInfo(result_str, "%s", value);
+           appendStringInfoString(result_str, value);
 
        p = att_addlength(p, typlen, PointerGetDatum(p));
        p = (char *) att_align(p, typalign);
index 33fd1e82ba6e22dd9a04561eba277bc4d943ed77..9e7264c9b32626d64263b1e854b17fcca7e6ed44 100644 (file)
@@ -10,7 +10,7 @@
  * Written by Peter Eisentraut .
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.181 2004/01/26 22:35:32 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.182 2004/01/31 05:09:41 neilc Exp $
  *
  *--------------------------------------------------------------------
  */
@@ -3259,7 +3259,7 @@ flatten_set_variable_args(const char *name, List *args)
                break;
            case T_Float:
                /* represented as a string, so just copy it */
-               appendStringInfo(&buf, "%s", strVal(&arg->val));
+               appendStringInfoString(&buf, strVal(&arg->val));
                break;
            case T_String:
                val = strVal(&arg->val);
@@ -3293,9 +3293,9 @@ flatten_set_variable_args(const char *name, List *args)
                     * mode, quote it if it's not a vanilla identifier.
                     */
                    if (flags & GUC_LIST_QUOTE)
-                       appendStringInfo(&buf, "%s", quote_identifier(val));
+                       appendStringInfoString(&buf, quote_identifier(val));
                    else
-                       appendStringInfo(&buf, "%s", val);
+                       appendStringInfoString(&buf, val);
                }
                break;
            default: