|
|
|
@ -34,6 +34,7 @@ |
|
|
|
|
#include <type_traits> |
|
|
|
|
|
|
|
|
|
#include "google/protobuf/port.h" |
|
|
|
|
#include "absl/log/absl_check.h" |
|
|
|
|
#include "google/protobuf/io/coded_stream.h" |
|
|
|
|
#include "google/protobuf/map.h" |
|
|
|
|
#include "google/protobuf/map_entry_lite.h" |
|
|
|
@ -51,10 +52,6 @@ namespace google { |
|
|
|
|
namespace protobuf { |
|
|
|
|
namespace internal { |
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG |
|
|
|
|
void MapFieldLiteNotDestructed(void* map_field_lite); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// This class provides access to map field using generated api. It is used for
|
|
|
|
|
// internal generated message implementation only. Users should never use this
|
|
|
|
|
// directly.
|
|
|
|
@ -75,10 +72,10 @@ class MapFieldLite { |
|
|
|
|
MapFieldLite(ArenaInitialized, Arena* arena) : MapFieldLite(arena) {} |
|
|
|
|
|
|
|
|
|
#ifdef NDEBUG |
|
|
|
|
void Destruct() { map_.~Map(); } |
|
|
|
|
~MapFieldLite() {} |
|
|
|
|
~MapFieldLite() { map_.~Map(); } |
|
|
|
|
#else |
|
|
|
|
void Destruct() { |
|
|
|
|
~MapFieldLite() { |
|
|
|
|
ABSL_DCHECK_EQ(map_.arena(), nullptr); |
|
|
|
|
// We want to destruct the map in such a way that we can verify
|
|
|
|
|
// that we've done that, but also be sure that we've deallocated
|
|
|
|
|
// everything (as opposed to leaving an allocation behind with no
|
|
|
|
@ -87,11 +84,6 @@ class MapFieldLite { |
|
|
|
|
decltype(map_) swapped_map(map_.arena()); |
|
|
|
|
map_.InternalSwap(&swapped_map); |
|
|
|
|
} |
|
|
|
|
~MapFieldLite() { |
|
|
|
|
if (map_.arena() == nullptr && !map_.empty()) { |
|
|
|
|
MapFieldLiteNotDestructed(this); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
// Accessors
|
|
|
|
|
const Map<Key, T>& GetMap() const { return map_; } |
|
|
|
@ -192,13 +184,6 @@ struct MapEntryToMapField< |
|
|
|
|
MapFieldType; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
#ifndef NDEBUG |
|
|
|
|
inline PROTOBUF_NOINLINE void MapFieldLiteNotDestructed(void* map_field_lite) { |
|
|
|
|
bool proper_destruct = false; |
|
|
|
|
ABSL_CHECK(proper_destruct) << map_field_lite; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
} // namespace protobuf
|
|
|
|
|
} // namespace google
|
|
|
|
|