Skip to content

Commit

Permalink
Auto-generate files after cl/707943424
Browse files Browse the repository at this point in the history
  • Loading branch information
protobuf-team-bot committed Dec 19, 2024
1 parent c78129d commit 7740bcb
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 48 deletions.
45 changes: 22 additions & 23 deletions php/ext/google/protobuf/php-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3919,8 +3919,10 @@ static int _upb_mapsorter_cmpext(const void* _a, const void* _b) {
}

bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Message_Internal* in,
size_t count, _upb_sortedmap* sorted) {
_upb_sortedmap* sorted) {
size_t count = (in->size - in->ext_begin) / sizeof(upb_Extension);
if (!_upb_mapsorter_resize(s, sorted, count)) return false;
if (count == 0) return true;
const upb_Extension* exts =
UPB_PTR_AT(in, in->ext_begin, const upb_Extension);

Expand Down Expand Up @@ -8288,28 +8290,25 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
/* Encode all extensions together. Unlike C++, we do not attempt to keep
* these in field number order relative to normal fields or even to each
* other. */
size_t ext_count = upb_Message_ExtensionCount(msg);
if (ext_count) {
if (e->options & kUpb_EncodeOption_Deterministic) {
_upb_sortedmap sorted;
if (!_upb_mapsorter_pushexts(&e->sorter, in, ext_count, &sorted)) {
// TODO: b/378744096 - handle alloc failure
}
const upb_Extension* ext;
while (_upb_sortedmap_nextext(&e->sorter, &sorted, &ext)) {
encode_ext(e, ext->ext, ext->data,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
const upb_MiniTableExtension* ext;
upb_MessageValue ext_val;
uintptr_t iter = kUpb_Message_ExtensionBegin;
while (UPB_PRIVATE(_upb_Message_NextExtensionReverse)(
msg, &ext, &ext_val, &iter)) {
encode_ext(e, ext, ext_val,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
if (e->options & kUpb_EncodeOption_Deterministic) {
_upb_sortedmap sorted;
if (!_upb_mapsorter_pushexts(&e->sorter, in, &sorted)) {
// TODO: b/378744096 - handle alloc failure
}
const upb_Extension* ext;
while (_upb_sortedmap_nextext(&e->sorter, &sorted, &ext)) {
encode_ext(e, ext->ext, ext->data,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
const upb_MiniTableExtension* ext;
upb_MessageValue ext_val;
uintptr_t iter = kUpb_Message_ExtensionBegin;
while (UPB_PRIVATE(_upb_Message_NextExtensionReverse)(
msg, &ext, &ext_val, &iter)) {
encode_ext(e, ext, ext_val,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion php/ext/google/protobuf/php-upb.h
Original file line number Diff line number Diff line change
Expand Up @@ -13886,7 +13886,7 @@ bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
const struct upb_Map* map, _upb_sortedmap* sorted);

bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Message_Internal* in,
size_t count, _upb_sortedmap* sorted);
_upb_sortedmap* sorted);

#ifdef __cplusplus
} /* extern "C" */
Expand Down
45 changes: 22 additions & 23 deletions ruby/ext/google/protobuf_c/ruby-upb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3919,8 +3919,10 @@ static int _upb_mapsorter_cmpext(const void* _a, const void* _b) {
}

bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Message_Internal* in,
size_t count, _upb_sortedmap* sorted) {
_upb_sortedmap* sorted) {
size_t count = (in->size - in->ext_begin) / sizeof(upb_Extension);
if (!_upb_mapsorter_resize(s, sorted, count)) return false;
if (count == 0) return true;
const upb_Extension* exts =
UPB_PTR_AT(in, in->ext_begin, const upb_Extension);

Expand Down Expand Up @@ -8288,28 +8290,25 @@ static void encode_message(upb_encstate* e, const upb_Message* msg,
/* Encode all extensions together. Unlike C++, we do not attempt to keep
* these in field number order relative to normal fields or even to each
* other. */
size_t ext_count = upb_Message_ExtensionCount(msg);
if (ext_count) {
if (e->options & kUpb_EncodeOption_Deterministic) {
_upb_sortedmap sorted;
if (!_upb_mapsorter_pushexts(&e->sorter, in, ext_count, &sorted)) {
// TODO: b/378744096 - handle alloc failure
}
const upb_Extension* ext;
while (_upb_sortedmap_nextext(&e->sorter, &sorted, &ext)) {
encode_ext(e, ext->ext, ext->data,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
const upb_MiniTableExtension* ext;
upb_MessageValue ext_val;
uintptr_t iter = kUpb_Message_ExtensionBegin;
while (UPB_PRIVATE(_upb_Message_NextExtensionReverse)(
msg, &ext, &ext_val, &iter)) {
encode_ext(e, ext, ext_val,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
if (e->options & kUpb_EncodeOption_Deterministic) {
_upb_sortedmap sorted;
if (!_upb_mapsorter_pushexts(&e->sorter, in, &sorted)) {
// TODO: b/378744096 - handle alloc failure
}
const upb_Extension* ext;
while (_upb_sortedmap_nextext(&e->sorter, &sorted, &ext)) {
encode_ext(e, ext->ext, ext->data,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
_upb_mapsorter_popmap(&e->sorter, &sorted);
} else {
const upb_MiniTableExtension* ext;
upb_MessageValue ext_val;
uintptr_t iter = kUpb_Message_ExtensionBegin;
while (UPB_PRIVATE(_upb_Message_NextExtensionReverse)(
msg, &ext, &ext_val, &iter)) {
encode_ext(e, ext, ext_val,
m->UPB_PRIVATE(ext) == kUpb_ExtMode_IsMessageSet);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion ruby/ext/google/protobuf_c/ruby-upb.h
Original file line number Diff line number Diff line change
Expand Up @@ -13888,7 +13888,7 @@ bool _upb_mapsorter_pushmap(_upb_mapsorter* s, upb_FieldType key_type,
const struct upb_Map* map, _upb_sortedmap* sorted);

bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Message_Internal* in,
size_t count, _upb_sortedmap* sorted);
_upb_sortedmap* sorted);

#ifdef __cplusplus
} /* extern "C" */
Expand Down

0 comments on commit 7740bcb

Please sign in to comment.