Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitcacbdd7

Browse files
committed
Use appendStringInfoString instead of appendStringInfo where possible.
This shaves a few cycles, and generally seems like good programmingpractice.David Rowley
1 parent343bb13 commitcacbdd7

33 files changed

+399
-404
lines changed

‎contrib/cube/cube.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -335,18 +335,18 @@ cube_out(PG_FUNCTION_ARGS)
335335
for (i=0;i<dim;i++)
336336
{
337337
if (i>0)
338-
appendStringInfo(&buf,", ");
338+
appendStringInfoString(&buf,", ");
339339
appendStringInfo(&buf,"%.*g",ndig,LL_COORD(cube,i));
340340
}
341341
appendStringInfoChar(&buf,')');
342342

343343
if (!cube_is_point_internal(cube))
344344
{
345-
appendStringInfo(&buf,",(");
345+
appendStringInfoString(&buf,",(");
346346
for (i=0;i<dim;i++)
347347
{
348348
if (i>0)
349-
appendStringInfo(&buf,", ");
349+
appendStringInfoString(&buf,", ");
350350
appendStringInfo(&buf,"%.*g",ndig,UR_COORD(cube,i));
351351
}
352352
appendStringInfoChar(&buf,')');

‎contrib/dblink/dblink.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,14 +2169,14 @@ get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
21692169
continue;
21702170

21712171
if (needComma)
2172-
appendStringInfo(&buf,",");
2172+
appendStringInfoChar(&buf,',');
21732173

21742174
appendStringInfoString(&buf,
21752175
quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname)));
21762176
needComma= true;
21772177
}
21782178

2179-
appendStringInfo(&buf,") VALUES(");
2179+
appendStringInfoString(&buf,") VALUES(");
21802180

21812181
/*
21822182
* Note: i is physical column number (counting from 0).
@@ -2188,7 +2188,7 @@ get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
21882188
continue;
21892189

21902190
if (needComma)
2191-
appendStringInfo(&buf,",");
2191+
appendStringInfoChar(&buf,',');
21922192

21932193
key=get_attnum_pk_pos(pkattnums,pknumatts,i);
21942194

@@ -2203,10 +2203,10 @@ get_sql_insert(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
22032203
pfree(val);
22042204
}
22052205
else
2206-
appendStringInfo(&buf,"NULL");
2206+
appendStringInfoString(&buf,"NULL");
22072207
needComma= true;
22082208
}
2209-
appendStringInfo(&buf,")");
2209+
appendStringInfoChar(&buf,')');
22102210

22112211
return (buf.data);
22122212
}
@@ -2232,7 +2232,7 @@ get_sql_delete(Relation rel, int *pkattnums, int pknumatts, char **tgt_pkattvals
22322232
intpkattnum=pkattnums[i];
22332233

22342234
if (i>0)
2235-
appendStringInfo(&buf," AND ");
2235+
appendStringInfoString(&buf," AND ");
22362236

22372237
appendStringInfoString(&buf,
22382238
quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum]->attname)));
@@ -2241,7 +2241,7 @@ get_sql_delete(Relation rel, int *pkattnums, int pknumatts, char **tgt_pkattvals
22412241
appendStringInfo(&buf," = %s",
22422242
quote_literal_cstr(tgt_pkattvals[i]));
22432243
else
2244-
appendStringInfo(&buf," IS NULL");
2244+
appendStringInfoString(&buf," IS NULL");
22452245
}
22462246

22472247
return (buf.data);
@@ -2286,7 +2286,7 @@ get_sql_update(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
22862286
continue;
22872287

22882288
if (needComma)
2289-
appendStringInfo(&buf,", ");
2289+
appendStringInfoString(&buf,", ");
22902290

22912291
appendStringInfo(&buf,"%s = ",
22922292
quote_ident_cstr(NameStr(tupdesc->attrs[i]->attname)));
@@ -2308,24 +2308,24 @@ get_sql_update(Relation rel, int *pkattnums, int pknumatts, char **src_pkattvals
23082308
needComma= true;
23092309
}
23102310

2311-
appendStringInfo(&buf," WHERE ");
2311+
appendStringInfoString(&buf," WHERE ");
23122312

23132313
for (i=0;i<pknumatts;i++)
23142314
{
23152315
intpkattnum=pkattnums[i];
23162316

23172317
if (i>0)
2318-
appendStringInfo(&buf," AND ");
2318+
appendStringInfoString(&buf," AND ");
23192319

2320-
appendStringInfo(&buf,"%s",
2320+
appendStringInfoString(&buf,
23212321
quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum]->attname)));
23222322

23232323
val=tgt_pkattvals[i];
23242324

23252325
if (val!=NULL)
23262326
appendStringInfo(&buf," = %s",quote_literal_cstr(val));
23272327
else
2328-
appendStringInfo(&buf," IS NULL");
2328+
appendStringInfoString(&buf," IS NULL");
23292329
}
23302330

23312331
return (buf.data);
@@ -2419,7 +2419,7 @@ get_tuple_of_interest(Relation rel, int *pkattnums, int pknumatts, char **src_pk
24192419
intpkattnum=pkattnums[i];
24202420

24212421
if (i>0)
2422-
appendStringInfo(&buf," AND ");
2422+
appendStringInfoString(&buf," AND ");
24232423

24242424
appendStringInfoString(&buf,
24252425
quote_ident_cstr(NameStr(tupdesc->attrs[pkattnum]->attname)));
@@ -2428,7 +2428,7 @@ get_tuple_of_interest(Relation rel, int *pkattnums, int pknumatts, char **src_pk
24282428
appendStringInfo(&buf," = %s",
24292429
quote_literal_cstr(src_pkattvals[i]));
24302430
else
2431-
appendStringInfo(&buf," IS NULL");
2431+
appendStringInfoString(&buf," IS NULL");
24322432
}
24332433

24342434
/*

‎contrib/pg_trgm/trgm_regexp.c

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1972,7 +1972,7 @@ printSourceNFA(regex_t *regex, TrgmColorInfo *colors, int ncolors)
19721972

19731973
initStringInfo(&buf);
19741974

1975-
appendStringInfo(&buf,"\ndigraph sourceNFA {\n");
1975+
appendStringInfoString(&buf,"\ndigraph sourceNFA {\n");
19761976

19771977
for (state=0;state<nstates;state++)
19781978
{
@@ -1982,8 +1982,8 @@ printSourceNFA(regex_t *regex, TrgmColorInfo *colors, int ncolors)
19821982

19831983
appendStringInfo(&buf,"s%d",state);
19841984
if (pg_reg_getfinalstate(regex)==state)
1985-
appendStringInfo(&buf," [shape = doublecircle]");
1986-
appendStringInfo(&buf,";\n");
1985+
appendStringInfoString(&buf," [shape = doublecircle]");
1986+
appendStringInfoString(&buf,";\n");
19871987

19881988
arcsCount=pg_reg_getnumoutarcs(regex,state);
19891989
arcs= (regex_arc_t*)palloc(sizeof(regex_arc_t)*arcsCount);
@@ -1998,13 +1998,13 @@ printSourceNFA(regex_t *regex, TrgmColorInfo *colors, int ncolors)
19981998
pfree(arcs);
19991999
}
20002000

2001-
appendStringInfo(&buf," node [shape = point ]; initial;\n");
2001+
appendStringInfoString(&buf," node [shape = point ]; initial;\n");
20022002
appendStringInfo(&buf," initial -> s%d;\n",
20032003
pg_reg_getinitialstate(regex));
20042004

20052005
/* Print colors */
2006-
appendStringInfo(&buf," { rank = sink;\n");
2007-
appendStringInfo(&buf," Colors [shape = none, margin=0, label=<\n");
2006+
appendStringInfoString(&buf," { rank = sink;\n");
2007+
appendStringInfoString(&buf," Colors [shape = none, margin=0, label=<\n");
20082008

20092009
for (i=0;i<ncolors;i++)
20102010
{
@@ -2020,17 +2020,17 @@ printSourceNFA(regex_t *regex, TrgmColorInfo *colors, int ncolors)
20202020

20212021
memcpy(s,color->wordChars[j].bytes,MAX_MULTIBYTE_CHAR_LEN);
20222022
s[MAX_MULTIBYTE_CHAR_LEN]='\0';
2023-
appendStringInfo(&buf,"%s",s);
2023+
appendStringInfoString(&buf,s);
20242024
}
20252025
}
20262026
else
2027-
appendStringInfo(&buf,"not expandable");
2028-
appendStringInfo(&buf,"\n");
2027+
appendStringInfoString(&buf,"not expandable");
2028+
appendStringInfoChar(&buf,'\n');
20292029
}
20302030

2031-
appendStringInfo(&buf," >];\n");
2032-
appendStringInfo(&buf," }\n");
2033-
appendStringInfo(&buf,"}\n");
2031+
appendStringInfoString(&buf," >];\n");
2032+
appendStringInfoString(&buf," }\n");
2033+
appendStringInfoString(&buf,"}\n");
20342034

20352035
{
20362036
/* dot -Tpng -o /tmp/source.png < /tmp/source.dot */
@@ -2056,7 +2056,7 @@ printTrgmNFA(TrgmNFA *trgmNFA)
20562056

20572057
initStringInfo(&buf);
20582058

2059-
appendStringInfo(&buf,"\ndigraph transformedNFA {\n");
2059+
appendStringInfoString(&buf,"\ndigraph transformedNFA {\n");
20602060

20612061
hash_seq_init(&scan_status,trgmNFA->states);
20622062
while ((state= (TrgmState*)hash_seq_search(&scan_status))!=NULL)
@@ -2065,11 +2065,11 @@ printTrgmNFA(TrgmNFA *trgmNFA)
20652065

20662066
appendStringInfo(&buf,"s%p", (void*)state);
20672067
if (state->fin)
2068-
appendStringInfo(&buf," [shape = doublecircle]");
2068+
appendStringInfoString(&buf," [shape = doublecircle]");
20692069
if (state->init)
20702070
initstate=state;
20712071
appendStringInfo(&buf," [label = \"%d\"]",state->stateKey.nstate);
2072-
appendStringInfo(&buf,";\n");
2072+
appendStringInfoString(&buf,";\n");
20732073

20742074
foreach(cell,state->arcs)
20752075
{
@@ -2078,21 +2078,21 @@ printTrgmNFA(TrgmNFA *trgmNFA)
20782078
appendStringInfo(&buf," s%p -> s%p [label = \"",
20792079
(void*)state, (void*)arc->target);
20802080
printTrgmColor(&buf,arc->ctrgm.colors[0]);
2081-
appendStringInfo(&buf," ");
2081+
appendStringInfoChar(&buf,' ');
20822082
printTrgmColor(&buf,arc->ctrgm.colors[1]);
2083-
appendStringInfo(&buf," ");
2083+
appendStringInfoChar(&buf,' ');
20842084
printTrgmColor(&buf,arc->ctrgm.colors[2]);
2085-
appendStringInfo(&buf,"\"];\n");
2085+
appendStringInfoString(&buf,"\"];\n");
20862086
}
20872087
}
20882088

20892089
if (initstate)
20902090
{
2091-
appendStringInfo(&buf," node [shape = point ]; initial;\n");
2091+
appendStringInfoString(&buf," node [shape = point ]; initial;\n");
20922092
appendStringInfo(&buf," initial -> s%p;\n", (void*)initstate);
20932093
}
20942094

2095-
appendStringInfo(&buf,"}\n");
2095+
appendStringInfoString(&buf,"}\n");
20962096

20972097
{
20982098
/* dot -Tpng -o /tmp/transformed.png < /tmp/transformed.dot */
@@ -2112,9 +2112,9 @@ static void
21122112
printTrgmColor(StringInfobuf,TrgmColorco)
21132113
{
21142114
if (co==COLOR_UNKNOWN)
2115-
appendStringInfo(buf,"u");
2115+
appendStringInfoChar(buf,'u');
21162116
elseif (co==COLOR_BLANK)
2117-
appendStringInfo(buf,"b");
2117+
appendStringInfoChar(buf,'b');
21182118
else
21192119
appendStringInfo(buf,"%d", (int)co);
21202120
}
@@ -2131,7 +2131,7 @@ printTrgmPackedGraph(TrgmPackedGraph *packedGraph, TRGM *trigrams)
21312131

21322132
initStringInfo(&buf);
21332133

2134-
appendStringInfo(&buf,"\ndigraph packedGraph {\n");
2134+
appendStringInfoString(&buf,"\ndigraph packedGraph {\n");
21352135

21362136
for (i=0;i<packedGraph->statesCount;i++)
21372137
{
@@ -2140,7 +2140,7 @@ printTrgmPackedGraph(TrgmPackedGraph *packedGraph, TRGM *trigrams)
21402140

21412141
appendStringInfo(&buf," s%d",i);
21422142
if (i==1)
2143-
appendStringInfo(&buf," [shape = doublecircle]");
2143+
appendStringInfoString(&buf," [shape = doublecircle]");
21442144

21452145
appendStringInfo(&buf," [label = <s%d>];\n",i);
21462146

@@ -2153,12 +2153,12 @@ printTrgmPackedGraph(TrgmPackedGraph *packedGraph, TRGM *trigrams)
21532153
}
21542154
}
21552155

2156-
appendStringInfo(&buf," node [shape = point ]; initial;\n");
2156+
appendStringInfoString(&buf," node [shape = point ]; initial;\n");
21572157
appendStringInfo(&buf," initial -> s%d;\n",0);
21582158

21592159
/* Print trigrams */
2160-
appendStringInfo(&buf," { rank = sink;\n");
2161-
appendStringInfo(&buf," Trigrams [shape = none, margin=0, label=<\n");
2160+
appendStringInfoString(&buf," { rank = sink;\n");
2161+
appendStringInfoString(&buf," Trigrams [shape = none, margin=0, label=<\n");
21622162

21632163
p=GETARR(trigrams);
21642164
for (i=0;i<packedGraph->colorTrigramsCount;i++)
@@ -2171,7 +2171,7 @@ printTrgmPackedGraph(TrgmPackedGraph *packedGraph, TRGM *trigrams)
21712171
for (j=0;j<count;j++)
21722172
{
21732173
if (j>0)
2174-
appendStringInfo(&buf,", ");
2174+
appendStringInfoString(&buf,", ");
21752175

21762176
/*
21772177
* XXX This representation is nice only for all-ASCII trigrams.
@@ -2181,9 +2181,9 @@ printTrgmPackedGraph(TrgmPackedGraph *packedGraph, TRGM *trigrams)
21812181
}
21822182
}
21832183

2184-
appendStringInfo(&buf," >];\n");
2185-
appendStringInfo(&buf," }\n");
2186-
appendStringInfo(&buf,"}\n");
2184+
appendStringInfoString(&buf," >];\n");
2185+
appendStringInfoString(&buf," }\n");
2186+
appendStringInfoString(&buf,"}\n");
21872187

21882188
{
21892189
/* dot -Tpng -o /tmp/packed.png < /tmp/packed.dot */

‎contrib/postgres_fdw/deparse.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ deparseInsertSql(StringInfo buf, PlannerInfo *root,
841841

842842
if (targetAttrs)
843843
{
844-
appendStringInfoString(buf,"(");
844+
appendStringInfoChar(buf,'(');
845845

846846
first= true;
847847
foreach(lc,targetAttrs)
@@ -869,7 +869,7 @@ deparseInsertSql(StringInfo buf, PlannerInfo *root,
869869
pindex++;
870870
}
871871

872-
appendStringInfoString(buf,")");
872+
appendStringInfoChar(buf,')');
873873
}
874874
else
875875
appendStringInfoString(buf," DEFAULT VALUES");
@@ -989,7 +989,7 @@ deparseAnalyzeSizeSql(StringInfo buf, Relation rel)
989989
initStringInfo(&relname);
990990
deparseRelation(&relname,rel);
991991

992-
appendStringInfo(buf,"SELECT pg_catalog.pg_relation_size(");
992+
appendStringInfoString(buf,"SELECT pg_catalog.pg_relation_size(");
993993
deparseStringLiteral(buf,relname.data);
994994
appendStringInfo(buf,"::pg_catalog.regclass) / %d",BLCKSZ);
995995
}
@@ -1302,7 +1302,7 @@ deparseConst(Const *node, deparse_expr_cxt *context)
13021302

13031303
if (node->constisnull)
13041304
{
1305-
appendStringInfo(buf,"NULL");
1305+
appendStringInfoString(buf,"NULL");
13061306
appendStringInfo(buf,"::%s",
13071307
format_type_with_typemod(node->consttype,
13081308
node->consttypmod));
@@ -1650,7 +1650,7 @@ deparseOperatorName(StringInfo buf, Form_pg_operator opform)
16501650
else
16511651
{
16521652
/* Just print operator name. */
1653-
appendStringInfo(buf,"%s",opname);
1653+
appendStringInfoString(buf,opname);
16541654
}
16551655
}
16561656

‎contrib/postgres_fdw/postgres_fdw.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ postgresGetForeignPlan(PlannerInfo *root,
787787
root->parse->commandType==CMD_DELETE))
788788
{
789789
/* Relation is UPDATE/DELETE target, so use FOR UPDATE */
790-
appendStringInfo(&sql," FOR UPDATE");
790+
appendStringInfoString(&sql," FOR UPDATE");
791791
}
792792
else
793793
{
@@ -808,11 +808,11 @@ postgresGetForeignPlan(PlannerInfo *root,
808808
{
809809
caseLCS_FORKEYSHARE:
810810
caseLCS_FORSHARE:
811-
appendStringInfo(&sql," FOR SHARE");
811+
appendStringInfoString(&sql," FOR SHARE");
812812
break;
813813
caseLCS_FORNOKEYUPDATE:
814814
caseLCS_FORUPDATE:
815-
appendStringInfo(&sql," FOR UPDATE");
815+
appendStringInfoString(&sql," FOR UPDATE");
816816
break;
817817
}
818818
}

‎contrib/tablefunc/tablefunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1340,7 +1340,7 @@ build_tuplestore_recursively(char *key_fld,
13401340
for (i=0;i<proc;i++)
13411341
{
13421342
/* initialize branch for this pass */
1343-
appendStringInfo(&branchstr,"%s",branch);
1343+
appendStringInfoString(&branchstr,branch);
13441344
appendStringInfo(&chk_branchstr,"%s%s%s",branch_delim,branch,branch_delim);
13451345

13461346
/* get the next sql result tuple */

‎src/backend/access/rmgrdesc/clogdesc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ clog_desc(StringInfo buf, uint8 xl_info, char *rec)
3737
appendStringInfo(buf,"truncate before: %d",pageno);
3838
}
3939
else
40-
appendStringInfo(buf,"UNKNOWN");
40+
appendStringInfoString(buf,"UNKNOWN");
4141
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp