Skip to content

Commit

Permalink
for performance: change JSONBCodec format to BinaryFormatCode.
Browse files Browse the repository at this point in the history
  • Loading branch information
piyongcai authored and piyongcai committed Nov 25, 2023
1 parent 7ebced9 commit e70fbe4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pgtype/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (JSONCodec) FormatSupported(format int16) bool {
}

func (JSONCodec) PreferredFormat() int16 {
return TextFormatCode
return BinaryFormatCode
}

func (c JSONCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
Expand Down
4 changes: 2 additions & 2 deletions pgtype/jsonb.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (JSONBCodec) FormatSupported(format int16) bool {
}

func (JSONBCodec) PreferredFormat() int16 {
return TextFormatCode
return BinaryFormatCode
}

func (JSONBCodec) PlanEncode(m *Map, oid uint32, format int16, value any) EncodePlan {
Expand Down Expand Up @@ -42,7 +42,7 @@ func (plan *encodePlanJSONBCodecBinaryWrapper) Encode(value any, buf []byte) (ne
func (JSONBCodec) PlanScan(m *Map, oid uint32, format int16, target any) ScanPlan {
switch format {
case BinaryFormatCode:
plan := JSONCodec{}.PlanScan(m, oid, TextFormatCode, target)
plan := JSONCodec{}.PlanScan(m, oid, BinaryFormatCode, target)
if plan != nil {
return &scanPlanJSONBCodecBinaryUnwrapper{textPlan: plan}
}
Expand Down

0 comments on commit e70fbe4

Please sign in to comment.