diff --git a/php/ext/google/protobuf/php-upb.c b/php/ext/google/protobuf/php-upb.c index 62c9f654ab..b919c5c24f 100644 --- a/php/ext/google/protobuf/php-upb.c +++ b/php/ext/google/protobuf/php-upb.c @@ -5961,11 +5961,9 @@ const upb_Extension* upb_Message_FindExtensionByNumber(const upb_Message* msg, // Must be last. -upb_MapInsertStatus upb_Message_InsertMapEntry(upb_Map* map, - const upb_MiniTable* mini_table, - const upb_MiniTableField* f, - upb_Message* map_entry_message, - upb_Arena* arena) { +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, + const upb_MiniTableField* f, + upb_Message* map_entry_message, upb_Arena* arena) { // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); @@ -5983,7 +5981,7 @@ upb_MapInsertStatus upb_Message_InsertMapEntry(upb_Map* map, upb_Message_GetField(map_entry_message, map_entry_key_field, default_val); upb_MessageValue map_entry_value = upb_Message_GetField( map_entry_message, map_entry_value_field, default_val); - return upb_Map_Insert(map, map_entry_key, map_entry_value, arena); + return upb_Map_Set(map, map_entry_key, map_entry_value, arena); } bool upb_Message_IsExactlyEqual(const upb_Message* m1, const upb_Message* m2, @@ -6090,8 +6088,7 @@ upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type, if (!upb_Clone_MessageValue(&val, value_field_type, value_sub, arena)) { return NULL; } - if (upb_Map_Insert(cloned_map, key, val, arena) == - kUpb_MapInsertStatus_OutOfMemory) { + if (!upb_Map_Set(cloned_map, key, val, arena)) { return NULL; } } diff --git a/php/ext/google/protobuf/php-upb.h b/php/ext/google/protobuf/php-upb.h index 95e64b9759..70a48ae104 100644 --- a/php/ext/google/protobuf/php-upb.h +++ b/php/ext/google/protobuf/php-upb.h @@ -1792,8 +1792,11 @@ const upb_Extension* _upb_Message_Getext(const upb_Message* msg, // EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// -#ifndef UPB_COLLECTIONS_INTERNAL_MAP_H_ -#define UPB_COLLECTIONS_INTERNAL_MAP_H_ +#ifndef UPB_MESSAGE_INTERNAL_MAP_H_ +#define UPB_MESSAGE_INTERNAL_MAP_H_ + +#include +#include #ifndef UPB_HASH_STR_TABLE_H_ @@ -2336,7 +2339,7 @@ upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size); #endif -#endif /* UPB_COLLECTIONS_INTERNAL_MAP_H_ */ +#endif /* UPB_MESSAGE_INTERNAL_MAP_H_ */ /* ** Our memory representation for parsing tables and messages themselves. @@ -3352,11 +3355,9 @@ UPB_API_INLINE upb_Map* upb_Message_GetOrCreateMutableMap( } // Updates a map entry given an entry message. -upb_MapInsertStatus upb_Message_InsertMapEntry(upb_Map* map, - const upb_MiniTable* mini_table, - const upb_MiniTableField* field, - upb_Message* map_entry_message, - upb_Arena* arena); +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, + const upb_MiniTableField* field, + upb_Message* map_entry_message, upb_Arena* arena); // Compares two messages by serializing them and calling memcmp(). bool upb_Message_IsExactlyEqual(const upb_Message* m1, const upb_Message* m2, @@ -12346,14 +12347,16 @@ void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src, // EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// -#ifndef UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ -#define UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ +#ifndef UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ +#define UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ #include -#ifndef UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ -#define UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ +#ifndef UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ +#define UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ + +#include // Map entries aren't actually stored for map fields, they are only used during @@ -12384,7 +12387,7 @@ typedef struct { upb_MapEntryData data; } upb_MapEntry; -#endif // UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ +#endif // UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ // Must be last. @@ -12453,7 +12456,7 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts, #endif -#endif /* UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ */ +#endif /* UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ */ #ifndef UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_ #define UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_ diff --git a/ruby/ext/google/protobuf_c/ruby-upb.c b/ruby/ext/google/protobuf_c/ruby-upb.c index 89431e8a71..50732bf20c 100644 --- a/ruby/ext/google/protobuf_c/ruby-upb.c +++ b/ruby/ext/google/protobuf_c/ruby-upb.c @@ -5475,11 +5475,9 @@ const upb_Extension* upb_Message_FindExtensionByNumber(const upb_Message* msg, // Must be last. -upb_MapInsertStatus upb_Message_InsertMapEntry(upb_Map* map, - const upb_MiniTable* mini_table, - const upb_MiniTableField* f, - upb_Message* map_entry_message, - upb_Arena* arena) { +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, + const upb_MiniTableField* f, + upb_Message* map_entry_message, upb_Arena* arena) { // TODO: use a variant of upb_MiniTable_GetSubMessageTable() here. const upb_MiniTable* map_entry_mini_table = upb_MiniTableSub_Message( mini_table->UPB_PRIVATE(subs)[f->UPB_PRIVATE(submsg_index)]); @@ -5497,7 +5495,7 @@ upb_MapInsertStatus upb_Message_InsertMapEntry(upb_Map* map, upb_Message_GetField(map_entry_message, map_entry_key_field, default_val); upb_MessageValue map_entry_value = upb_Message_GetField( map_entry_message, map_entry_value_field, default_val); - return upb_Map_Insert(map, map_entry_key, map_entry_value, arena); + return upb_Map_Set(map, map_entry_key, map_entry_value, arena); } bool upb_Message_IsExactlyEqual(const upb_Message* m1, const upb_Message* m2, @@ -5604,8 +5602,7 @@ upb_Map* upb_Map_DeepClone(const upb_Map* map, upb_CType key_type, if (!upb_Clone_MessageValue(&val, value_field_type, value_sub, arena)) { return NULL; } - if (upb_Map_Insert(cloned_map, key, val, arena) == - kUpb_MapInsertStatus_OutOfMemory) { + if (!upb_Map_Set(cloned_map, key, val, arena)) { return NULL; } } diff --git a/ruby/ext/google/protobuf_c/ruby-upb.h b/ruby/ext/google/protobuf_c/ruby-upb.h index 9b92b33700..5e3b140168 100755 --- a/ruby/ext/google/protobuf_c/ruby-upb.h +++ b/ruby/ext/google/protobuf_c/ruby-upb.h @@ -1794,8 +1794,11 @@ const upb_Extension* _upb_Message_Getext(const upb_Message* msg, // EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// -#ifndef UPB_COLLECTIONS_INTERNAL_MAP_H_ -#define UPB_COLLECTIONS_INTERNAL_MAP_H_ +#ifndef UPB_MESSAGE_INTERNAL_MAP_H_ +#define UPB_MESSAGE_INTERNAL_MAP_H_ + +#include +#include #ifndef UPB_HASH_STR_TABLE_H_ @@ -2338,7 +2341,7 @@ upb_Map* _upb_Map_New(upb_Arena* a, size_t key_size, size_t value_size); #endif -#endif /* UPB_COLLECTIONS_INTERNAL_MAP_H_ */ +#endif /* UPB_MESSAGE_INTERNAL_MAP_H_ */ /* ** Our memory representation for parsing tables and messages themselves. @@ -3354,11 +3357,9 @@ UPB_API_INLINE upb_Map* upb_Message_GetOrCreateMutableMap( } // Updates a map entry given an entry message. -upb_MapInsertStatus upb_Message_InsertMapEntry(upb_Map* map, - const upb_MiniTable* mini_table, - const upb_MiniTableField* field, - upb_Message* map_entry_message, - upb_Arena* arena); +bool upb_Message_SetMapEntry(upb_Map* map, const upb_MiniTable* mini_table, + const upb_MiniTableField* field, + upb_Message* map_entry_message, upb_Arena* arena); // Compares two messages by serializing them and calling memcmp(). bool upb_Message_IsExactlyEqual(const upb_Message* m1, const upb_Message* m2, @@ -12118,14 +12119,16 @@ void upb_Message_ShallowCopy(upb_Message* dst, const upb_Message* src, // EVERYTHING BELOW THIS LINE IS INTERNAL - DO NOT USE ///////////////////////// -#ifndef UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ -#define UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ +#ifndef UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ +#define UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ #include -#ifndef UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ -#define UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ +#ifndef UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ +#define UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ + +#include // Map entries aren't actually stored for map fields, they are only used during @@ -12156,7 +12159,7 @@ typedef struct { upb_MapEntryData data; } upb_MapEntry; -#endif // UPB_COLLECTIONS_INTERNAL_MAP_ENTRY_H_ +#endif // UPB_MESSAGE_INTERNAL_MAP_ENTRY_H_ // Must be last. @@ -12225,7 +12228,7 @@ bool _upb_mapsorter_pushexts(_upb_mapsorter* s, const upb_Extension* exts, #endif -#endif /* UPB_COLLECTIONS_INTERNAL_MAP_SORTER_H_ */ +#endif /* UPB_MESSAGE_INTERNAL_MAP_SORTER_H_ */ #ifndef UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_ #define UPB_MINI_DESCRIPTOR_INTERNAL_BASE92_H_