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

Commit33a33f0

Browse files
committed
Use appendStringInfoString instead of appendBinaryStringInfo where possible
For the jsonpath output, we don't need to squeeze out every bit ofperformance, so instead use a more robust coding style. There aresimilar calls in jsonb.c, which we leave alone here since there isindeed a performance impact for bulk exports.Discussion:https://www.postgresql.org/message-id/flat/a0086cfc-ff0f-2827-20fe-52b591d2666c%40enterprisedb.com
1 parentfaf3750 commit33a33f0

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

‎src/backend/utils/adt/jsonpath.c

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ jsonPathToCstring(StringInfo out, JsonPath *in, int estimated_len)
221221
enlargeStringInfo(out,estimated_len);
222222

223223
if (!(in->header&JSONPATH_LAX))
224-
appendBinaryStringInfo(out,"strict ",7);
224+
appendStringInfoString(out,"strict ");
225225

226226
jspInit(&v,in);
227227
printJsonPathItem(out,&v, false, true);
@@ -542,9 +542,9 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
542542
break;
543543
casejpiBool:
544544
if (jspGetBool(v))
545-
appendBinaryStringInfo(buf,"true",4);
545+
appendStringInfoString(buf,"true");
546546
else
547-
appendBinaryStringInfo(buf,"false",5);
547+
appendStringInfoString(buf,"false");
548548
break;
549549
casejpiAnd:
550550
casejpiOr:
@@ -585,13 +585,13 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
585585
operationPriority(elem.type) <=
586586
operationPriority(v->type));
587587

588-
appendBinaryStringInfo(buf," like_regex ",12);
588+
appendStringInfoString(buf," like_regex ");
589589

590590
escape_json(buf,v->content.like_regex.pattern);
591591

592592
if (v->content.like_regex.flags)
593593
{
594-
appendBinaryStringInfo(buf," flag \"",7);
594+
appendStringInfoString(buf," flag \"");
595595

596596
if (v->content.like_regex.flags&JSP_REGEX_ICASE)
597597
appendStringInfoChar(buf,'i');
@@ -623,13 +623,13 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
623623
appendStringInfoChar(buf,')');
624624
break;
625625
casejpiFilter:
626-
appendBinaryStringInfo(buf,"?(",2);
626+
appendStringInfoString(buf,"?(");
627627
jspGetArg(v,&elem);
628628
printJsonPathItem(buf,&elem, false, false);
629629
appendStringInfoChar(buf,')');
630630
break;
631631
casejpiNot:
632-
appendBinaryStringInfo(buf,"!(",2);
632+
appendStringInfoString(buf,"!(");
633633
jspGetArg(v,&elem);
634634
printJsonPathItem(buf,&elem, false, false);
635635
appendStringInfoChar(buf,')');
@@ -638,10 +638,10 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
638638
appendStringInfoChar(buf,'(');
639639
jspGetArg(v,&elem);
640640
printJsonPathItem(buf,&elem, false, false);
641-
appendBinaryStringInfo(buf,") is unknown",12);
641+
appendStringInfoString(buf,") is unknown");
642642
break;
643643
casejpiExists:
644-
appendBinaryStringInfo(buf,"exists (",8);
644+
appendStringInfoString(buf,"exists (");
645645
jspGetArg(v,&elem);
646646
printJsonPathItem(buf,&elem, false, false);
647647
appendStringInfoChar(buf,')');
@@ -655,10 +655,10 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
655655
appendStringInfoChar(buf,'$');
656656
break;
657657
casejpiLast:
658-
appendBinaryStringInfo(buf,"last",4);
658+
appendStringInfoString(buf,"last");
659659
break;
660660
casejpiAnyArray:
661-
appendBinaryStringInfo(buf,"[*]",3);
661+
appendStringInfoString(buf,"[*]");
662662
break;
663663
casejpiAnyKey:
664664
if (inKey)
@@ -680,7 +680,7 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
680680

681681
if (range)
682682
{
683-
appendBinaryStringInfo(buf," to ",4);
683+
appendStringInfoString(buf," to ");
684684
printJsonPathItem(buf,&to, false, false);
685685
}
686686
}
@@ -692,7 +692,7 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
692692

693693
if (v->content.anybounds.first==0&&
694694
v->content.anybounds.last==PG_UINT32_MAX)
695-
appendBinaryStringInfo(buf,"**",2);
695+
appendStringInfoString(buf,"**");
696696
elseif (v->content.anybounds.first==v->content.anybounds.last)
697697
{
698698
if (v->content.anybounds.first==PG_UINT32_MAX)
@@ -713,25 +713,25 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
713713
v->content.anybounds.last);
714714
break;
715715
casejpiType:
716-
appendBinaryStringInfo(buf,".type()",7);
716+
appendStringInfoString(buf,".type()");
717717
break;
718718
casejpiSize:
719-
appendBinaryStringInfo(buf,".size()",7);
719+
appendStringInfoString(buf,".size()");
720720
break;
721721
casejpiAbs:
722-
appendBinaryStringInfo(buf,".abs()",6);
722+
appendStringInfoString(buf,".abs()");
723723
break;
724724
casejpiFloor:
725-
appendBinaryStringInfo(buf,".floor()",8);
725+
appendStringInfoString(buf,".floor()");
726726
break;
727727
casejpiCeiling:
728-
appendBinaryStringInfo(buf,".ceiling()",10);
728+
appendStringInfoString(buf,".ceiling()");
729729
break;
730730
casejpiDouble:
731-
appendBinaryStringInfo(buf,".double()",9);
731+
appendStringInfoString(buf,".double()");
732732
break;
733733
casejpiDatetime:
734-
appendBinaryStringInfo(buf,".datetime(",10);
734+
appendStringInfoString(buf,".datetime(");
735735
if (v->content.arg)
736736
{
737737
jspGetArg(v,&elem);
@@ -740,7 +740,7 @@ printJsonPathItem(StringInfo buf, JsonPathItem *v, bool inKey,
740740
appendStringInfoChar(buf,')');
741741
break;
742742
casejpiKeyValue:
743-
appendBinaryStringInfo(buf,".keyvalue()",11);
743+
appendStringInfoString(buf,".keyvalue()");
744744
break;
745745
default:
746746
elog(ERROR,"unrecognized jsonpath item type: %d",v->type);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp