Internal Change

PiperOrigin-RevId: 634000296
pull/16851/head
Hong Shin 11 months ago committed by Copybara-Service
parent cfea7596c1
commit 3574af2397
  1. 2
      conformance/binary_json_conformance_suite.cc
  2. 4
      docs/design/editions/life-of-an-edition.md
  3. 6
      php/src/Google/Protobuf/Internal/FieldOptions.php
  4. 4
      src/google/protobuf/io/coded_stream.h
  5. 6
      src/google/protobuf/message_lite.h
  6. 2
      src/google/protobuf/text_format.cc
  7. 2
      src/google/protobuf/wire_format.h

@ -1353,7 +1353,7 @@ void BinaryAndJsonConformanceSuiteImpl<MessageType>::TestUnknownOrdering() {
// Implementations must preserve the ordering of different unknown fields for // Implementations must preserve the ordering of different unknown fields for
// the same field number. This is because some field types will accept // the same field number. This is because some field types will accept
// multiple wire types for the same field. For example, repeated primitive // multiple wire types for the same field. For example, repeated primitive
// fields will accept both length-delimited (packed) and // fields will accept both length-prefixed (packed) and
// varint/fixed32/fixed64 (unpacked) wire types, and reordering these could // varint/fixed32/fixed64 (unpacked) wire types, and reordering these could
// reorder the elements of the repeated field. // reorder the elements of the repeated field.
MessageType message; MessageType message;

@ -247,7 +247,7 @@ Once we have eliminated all the legacy accessors, we will remove the feature
### Large-scale Changes with Wire Format Break: Group-Encoded Messages ### Large-scale Changes with Wire Format Break: Group-Encoded Messages
It turns out that encoding and decoding groups (end-marker-delimited It turns out that encoding and decoding groups (end-marker-delimited
submessages) is cheaper than handling length-delimited messages. There are submessages) is cheaper than handling length-prefixed messages. There are
likely CPU and RAM savings in switching messages to use the group encoding. likely CPU and RAM savings in switching messages to use the group encoding.
Unfortunately, that would be a wire-breaking change, causing old readers to be Unfortunately, that would be a wire-breaking change, causing old readers to be
unable to parse new messages. unable to parse new messages.
@ -267,7 +267,7 @@ Once we are 95% done, we will upgrade protoc to set `features.group_encoded` to
true by default in new editions. Tooling can be used to clean up features as true by default in new editions. Tooling can be used to clean up features as
before. before.
We will probably never completely eliminate length-delimited messages, so this We will probably never completely eliminate length-prefixed messages, so this
is a rare case where the feature lives on forever. is a rare case where the feature lives on forever.
## Large-scale Change Tooling ## Large-scale Change Tooling

@ -28,7 +28,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* The packed option can be enabled for repeated primitive fields to enable * The packed option can be enabled for repeated primitive fields to enable
* a more efficient representation on the wire. Rather than repeatedly * a more efficient representation on the wire. Rather than repeatedly
* writing the tag and type for each element, the entire array is encoded as * writing the tag and type for each element, the entire array is encoded as
* a single length-delimited blob. In proto3, only explicit setting it to * a single length-prefixed blob. In proto3, only explicit setting it to
* false will avoid using packed encoding. * false will avoid using packed encoding.
* *
* Generated from protobuf field <code>optional bool packed = 2;</code> * Generated from protobuf field <code>optional bool packed = 2;</code>
@ -125,7 +125,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* The packed option can be enabled for repeated primitive fields to enable * The packed option can be enabled for repeated primitive fields to enable
* a more efficient representation on the wire. Rather than repeatedly * a more efficient representation on the wire. Rather than repeatedly
* writing the tag and type for each element, the entire array is encoded as * writing the tag and type for each element, the entire array is encoded as
* a single length-delimited blob. In proto3, only explicit setting it to * a single length-prefixed blob. In proto3, only explicit setting it to
* false will avoid using packed encoding. * false will avoid using packed encoding.
* @type int $jstype * @type int $jstype
* The jstype option determines the JavaScript type used for values of the * The jstype option determines the JavaScript type used for values of the
@ -231,7 +231,7 @@ class FieldOptions extends \Google\Protobuf\Internal\Message
* The packed option can be enabled for repeated primitive fields to enable * The packed option can be enabled for repeated primitive fields to enable
* a more efficient representation on the wire. Rather than repeatedly * a more efficient representation on the wire. Rather than repeatedly
* writing the tag and type for each element, the entire array is encoded as * writing the tag and type for each element, the entire array is encoded as
* a single length-delimited blob. In proto3, only explicit setting it to * a single length-prefixed blob. In proto3, only explicit setting it to
* false will avoid using packed encoding. * false will avoid using packed encoding.
* *
* Generated from protobuf field <code>optional bool packed = 2;</code> * Generated from protobuf field <code>optional bool packed = 2;</code>

@ -23,7 +23,7 @@
// //
// CodedOutputStream example: // CodedOutputStream example:
// // Write some data to "myfile". First we write a 4-byte "magic number" // // Write some data to "myfile". First we write a 4-byte "magic number"
// // to identify the file type, then write a length-delimited string. The // // to identify the file type, then write a length-prefixed string. The
// // string is composed of a varint giving the length followed by the raw // // string is composed of a varint giving the length followed by the raw
// // bytes. // // bytes.
// int fd = open("myfile", O_CREAT | O_WRONLY); // int fd = open("myfile", O_CREAT | O_WRONLY);
@ -313,7 +313,7 @@ class PROTOBUF_EXPORT CodedInputStream {
void SetConsumed() { legitimate_message_end_ = true; } void SetConsumed() { legitimate_message_end_ = true; }
// Limits ---------------------------------------------------------- // Limits ----------------------------------------------------------
// Limits are used when parsing length-delimited embedded messages. // Limits are used when parsing length-prefixed embedded messages.
// After the message's length is read, PushLimit() is used to prevent // After the message's length is read, PushLimit() is used to prevent
// the CodedInputStream from reading beyond that length. Once the // the CodedInputStream from reading beyond that length. Once the
// embedded message has been parsed, PopLimit() is called to undo the // embedded message has been parsed, PopLimit() is called to undo the

@ -490,9 +490,11 @@ class PROTOBUF_EXPORT MessageLite {
uint8_t* SerializeWithCachedSizesToArray(uint8_t* target) const; uint8_t* SerializeWithCachedSizesToArray(uint8_t* target) const;
// Returns the result of the last call to ByteSize(). An embedded message's // Returns the result of the last call to ByteSize(). An embedded message's
// size is needed both to serialize it (because embedded messages are // size is needed both to serialize it (only true for length-prefixed
// length-delimited) and to compute the outer message's size. Caching // submessages) and to compute the outer message's size. Caching
// the size avoids computing it multiple times. // the size avoids computing it multiple times.
// Note that the submessage size is unnecessary when using
// group encoding / delimited since we have SGROUP/EGROUP bounds.
// //
// ByteSize() does not automatically use the cached size when available // ByteSize() does not automatically use the cached size when available
// because this would require invalidating it every time the message was // because this would require invalidating it every time the message was

@ -2300,7 +2300,7 @@ bool TextFormat::Printer::Print(const Message& message,
return !generator.failed(); return !generator.failed();
} }
// Maximum recursion depth for heuristically printing out length-delimited // Maximum recursion depth for heuristically printing out length-prefixed
// unknown fields as messages. // unknown fields as messages.
static constexpr int kUnknownFieldRecursionLimit = 10; static constexpr int kUnknownFieldRecursionLimit = 10;

@ -242,7 +242,7 @@ class PROTOBUF_EXPORT WireFormat {
// Computes the byte size of a field, excluding tags. For packed fields, it // Computes the byte size of a field, excluding tags. For packed fields, it
// only includes the size of the raw data, and not the size of the total // only includes the size of the raw data, and not the size of the total
// length, but for other length-delimited types, the size of the length is // length, but for other length-prefixed types, the size of the length is
// included. // included.
static size_t FieldDataOnlyByteSize( static size_t FieldDataOnlyByteSize(
const FieldDescriptor* field, // Cannot be nullptr const FieldDescriptor* field, // Cannot be nullptr

Loading…
Cancel
Save