Skip to content

Commit b8e7192

Browse files
Update usage disclaimer on FieldOptions.ctype
FieldOptions.ctype is public and CORD support is implemented for [ctype=CORD] on "bytes" fields. Include a public comment for CORD about use and supported types. PiperOrigin-RevId: 524383969
1 parent faf9e8d commit b8e7192

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/google/protobuf/descriptor.proto

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,21 @@ message MessageOptions {
569569
message FieldOptions {
570570
// The ctype option instructs the C++ code generator to use a different
571571
// representation of the field than it normally would. See the specific
572-
// options below. This option is not yet implemented in the open source
573-
// release -- sorry, we'll try to include it in a future version!
572+
// options below. This option is only implemented to support use of
573+
// [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
574+
// type "bytes" in the open source release -- sorry, we'll try to include
575+
// other types in a future version!
574576
optional CType ctype = 1 [default = STRING];
575577
enum CType {
576578
// Default mode.
577579
STRING = 0;
578580

581+
// The option [ctype=CORD] may be applied to a non-repeated field of type
582+
// "bytes". It indicates that in C++, the data should be stored in a Cord
583+
// instead of a string. For very large strings, this may reduce memory
584+
// fragmentation. It may also allow better performance when parsing from a
585+
// Cord, or when parsing with aliasing enabled, as the parsed Cord may then
586+
// alias the original buffer.
579587
CORD = 1;
580588

581589
STRING_PIECE = 2;

0 commit comments

Comments
 (0)