Skip to content

Commit

Permalink
Reflection-based Proto2Json: Don't copy JSON when writing into a string
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim-xd committed Dec 22, 2023
1 parent 002a753 commit 4e97425
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions library/cpp/protobuf/json/json_writer_output.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace NProtobufJson {
{
}

private:
protected:
static NJson::TJsonWriterConfig CreateJsonWriterConfig(const TProto2JsonConfig& cfg);
};

Expand All @@ -95,7 +95,8 @@ namespace NProtobufJson {
template <typename TConfig>
TJsonStringWriterOutput(TString* str, const TConfig& cfg)
: TEmbedPolicy<TStringOutput>(*str)
, TJsonWriterOutput(TEmbedPolicy<TStringOutput>::Ptr(), cfg)
// If Unbuffered = false, TJsonWriter uses its own string and then flushes it into TStringOutput.
, TJsonWriterOutput(TEmbedPolicy<TStringOutput>::Ptr(), CreateJsonWriterConfig(cfg).SetUnbuffered(true))
{
}
};
Expand Down

0 comments on commit 4e97425

Please sign in to comment.