Skip to content

Commit 5411fc6

Browse files
TextFormat::ParseFieldValueFromString now takes absl::string_view as input instead of const std::string &
`TextFormat::ParseFieldValueFromString` would take `const std::string &` as the input, but it's a read-only string and immediately passed to `ArrayInputStream`. This CL will change it to `absl::string_view`. PiperOrigin-RevId: 540609068
1 parent 0a45abe commit 5411fc6

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/google/protobuf/text_format.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,7 +1794,7 @@ bool TextFormat::Parser::MergeUsingImpl(io::ZeroCopyInputStream* /* input */,
17941794
return true;
17951795
}
17961796

1797-
bool TextFormat::Parser::ParseFieldValueFromString(const std::string& input,
1797+
bool TextFormat::Parser::ParseFieldValueFromString(absl::string_view input,
17981798
const FieldDescriptor* field,
17991799
Message* output) {
18001800
io::ArrayInputStream input_stream(input.data(), input.size());
@@ -2757,7 +2757,7 @@ void TextFormat::Printer::PrintFieldValue(const Message& message,
27572757
}
27582758

27592759
/* static */ bool TextFormat::ParseFieldValueFromString(
2760-
const std::string& input, const FieldDescriptor* field, Message* message) {
2760+
absl::string_view input, const FieldDescriptor* field, Message* message) {
27612761
return Parser().ParseFieldValueFromString(input, field, message);
27622762
}
27632763

src/google/protobuf/text_format.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ class PROTOBUF_EXPORT TextFormat {
590590
// Parse the given text as a single field value and store it into the
591591
// given field of the given message. If the field is a repeated field,
592592
// the new value will be added to the end
593-
static bool ParseFieldValueFromString(const std::string& input,
593+
static bool ParseFieldValueFromString(absl::string_view input,
594594
const FieldDescriptor* field,
595595
Message* message);
596596

@@ -707,7 +707,7 @@ class PROTOBUF_EXPORT TextFormat {
707707
}
708708

709709
// Like TextFormat::ParseFieldValueFromString
710-
bool ParseFieldValueFromString(const std::string& input,
710+
bool ParseFieldValueFromString(absl::string_view input,
711711
const FieldDescriptor* field,
712712
Message* output);
713713

0 commit comments

Comments
 (0)