From d36c0c538a545fac5d9db6ba65c525246d4efa95 Mon Sep 17 00:00:00 2001 From: Feng Xiao Date: Wed, 29 Mar 2017 14:32:48 -0700 Subject: Down-integrate from google3. --- src/google/protobuf/map_type_handler.h | 70 ++++++++++++++++------------------ 1 file changed, 33 insertions(+), 37 deletions(-) (limited to 'src/google/protobuf/map_type_handler.h') diff --git a/src/google/protobuf/map_type_handler.h b/src/google/protobuf/map_type_handler.h index ac987cbc..301b37fe 100644 --- a/src/google/protobuf/map_type_handler.h +++ b/src/google/protobuf/map_type_handler.h @@ -186,9 +186,9 @@ class MapTypeHandler { static inline Type* EnsureMutable(Type** value, Arena* arena); // SpaceUsedInMapEntry: Return bytes used by value in MapEntry, excluding // those already calculate in sizeof(MapField). - static inline int SpaceUsedInMapEntry(const Type* value); + static inline size_t SpaceUsedInMapEntryLong(const Type* value); // Return bytes used by value in Map. - static inline int SpaceUsedInMap(const Type& value); + static inline size_t SpaceUsedInMapLong(const Type& value); // Assign default value to given instance. static inline void AssignDefaultValue(Type** value); // Return default instance if value is not initialized when calling const @@ -224,9 +224,7 @@ class MapTypeHandler { static inline void Write(int field, const MapEntryAccessorType& value, \ io::CodedOutputStream* output); \ static inline uint8* InternalWriteToArray( \ - int field, \ - const MapEntryAccessorType& value, \ - bool deterministic, \ + int field, const MapEntryAccessorType& value, bool deterministic, \ uint8* target); \ static inline uint8* WriteToArray(int field, \ const MapEntryAccessorType& value, \ @@ -242,9 +240,9 @@ class MapTypeHandler { static inline void ClearMaybeByDefaultEnum(TypeOnMemory* value, \ Arena* arena, \ int default_enum); \ - static inline int SpaceUsedInMapEntry(const TypeOnMemory& value); \ - static inline int SpaceUsedInMap(const TypeOnMemory& value); \ - static inline int SpaceUsedInMap(const string& value); \ + static inline size_t SpaceUsedInMapEntryLong(const TypeOnMemory& value); \ + static inline size_t SpaceUsedInMapLong(const TypeOnMemory& value); \ + static inline size_t SpaceUsedInMapLong(const string& value); \ static inline void AssignDefaultValue(TypeOnMemory* value); \ static inline const MapEntryAccessorType& DefaultIfNotInitialized( \ const TypeOnMemory& value, const TypeOnMemory& default_value); \ @@ -467,16 +465,15 @@ MapTypeHandler -inline int -MapTypeHandler::SpaceUsedInMapEntry(const Type* value) { - return value->SpaceUsed(); +inline size_t MapTypeHandler::SpaceUsedInMapEntryLong(const Type* value) { + return value->SpaceUsedLong(); } template -int MapTypeHandler::SpaceUsedInMap( +size_t MapTypeHandler::SpaceUsedInMapLong( const Type& value) { - return value.SpaceUsed(); + return value.SpaceUsedLong(); } template @@ -507,7 +504,7 @@ void MapTypeHandler::DeleteNoArena( template inline void MapTypeHandler::AssignDefaultValue(Type** value) { - *value = const_cast(&Type::default_instance()); + *value = const_cast(Type::internal_default_instance()); } template @@ -559,19 +556,21 @@ inline bool MapTypeHandler \ - inline int \ - MapTypeHandler::SpaceUsedInMapEntry( \ - const TypeOnMemory& value) { \ + inline size_t \ + MapTypeHandler::SpaceUsedInMapEntryLong(const TypeOnMemory& value) { \ return sizeof(value); \ } \ template \ - inline int MapTypeHandler::SpaceUsedInMap(const TypeOnMemory& value) { \ + inline size_t \ + MapTypeHandler::SpaceUsedInMapLong( \ + const TypeOnMemory& value) { \ return sizeof(value); \ } \ template \ - inline int MapTypeHandler::SpaceUsedInMap(const string& value) { \ + inline size_t \ + MapTypeHandler::SpaceUsedInMapLong( \ + const string& value) { \ return sizeof(value); \ } \ template \ @@ -647,14 +646,15 @@ STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES) return value; \ } \ template \ - inline int \ - MapTypeHandler::SpaceUsedInMapEntry( \ - const TypeOnMemory& value) { \ + inline size_t \ + MapTypeHandler::SpaceUsedInMapEntryLong(const TypeOnMemory& value) { \ return 0; \ } \ template \ - inline int MapTypeHandler::SpaceUsedInMap(const TypeOnMemory& value) { \ + inline size_t \ + MapTypeHandler::SpaceUsedInMapLong( \ + const TypeOnMemory& value) { \ return sizeof(Type); \ } \ template \ @@ -663,11 +663,9 @@ STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES) *value = 0; \ } \ template \ - inline void \ - MapTypeHandler::ClearMaybeByDefaultEnum(TypeOnMemory* value, \ - Arena* arena, \ - int default_enum_value) { \ + inline void MapTypeHandler:: \ + ClearMaybeByDefaultEnum(TypeOnMemory* value, Arena* arena, \ + int default_enum_value) { \ *value = static_cast(default_enum_value); \ } \ template \ @@ -688,11 +686,9 @@ STRING_OR_BYTES_HANDLER_FUNCTIONS(BYTES) *value = 0; \ } \ template \ - inline void \ - MapTypeHandler::InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ - int default_enum_value, \ - Arena* arena) { \ + inline void MapTypeHandler:: \ + InitializeMaybeByDefaultEnum(TypeOnMemory* value, \ + int default_enum_value, Arena* arena) { \ *value = static_cast(default_enum_value); \ } \ template \ -- cgit v1.2.3