`MapEntry` no longer needs `Derived` template parameter.

Removed some dead code from `MapField`.

PiperOrigin-RevId: 669361776
pull/18019/head
Protobuf Team Bot 7 months ago committed by Copybara-Service
parent ee9c176e73
commit bd4162ad51
  1. 4
      src/google/protobuf/compiler/cpp/message.cc
  2. 20
      src/google/protobuf/map_entry.h
  3. 18
      src/google/protobuf/map_field.h
  4. 2
      src/google/protobuf/map_test.inc

@ -1368,12 +1368,12 @@ void MessageGenerator::GenerateMapEntryClassDefinition(io::Printer* p) {
R"cc(
class $classname$ final
: public ::$proto_ns$::internal::MapEntry<
$classname$, $key_cpp$, $val_cpp$,
$key_cpp$, $val_cpp$,
::$proto_ns$::internal::WireFormatLite::$key_wire_type$,
::$proto_ns$::internal::WireFormatLite::$val_wire_type$> {
public:
using SuperType = ::$proto_ns$::internal::MapEntry<
$classname$, $key_cpp$, $val_cpp$,
$key_cpp$, $val_cpp$,
::$proto_ns$::internal::WireFormatLite::$key_wire_type$,
::$proto_ns$::internal::WireFormatLite::$val_wire_type$>;
$classname$();

@ -30,18 +30,9 @@
namespace google {
namespace protobuf {
class Arena;
namespace internal {
template <typename Derived, typename Key, typename Value,
WireFormatLite::FieldType kKeyFieldType,
WireFormatLite::FieldType kValueFieldType>
class MapField;
}
} // namespace protobuf
} // namespace google
namespace google {
namespace protobuf {
namespace internal {
// MapEntry is the returned google::protobuf::Message when calling AddMessage of
@ -70,8 +61,7 @@ namespace internal {
// The in-memory types of primitive types can be inferred from its proto type,
// while we need to explicitly specify the cpp type if proto type is
// TYPE_MESSAGE to infer the in-memory type.
template <typename Derived, typename Key, typename Value,
WireFormatLite::FieldType kKeyFieldType,
template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,
WireFormatLite::FieldType kValueFieldType>
class MapEntry : public Message {
// Provide utilities to parse/serialize key/value. Provide utilities to
@ -119,11 +109,9 @@ class MapEntry : public Message {
} _impl_;
};
template <typename Derived, typename Key, typename Value,
WireFormatLite::FieldType kKeyFieldType,
template <typename Key, typename Value, WireFormatLite::FieldType kKeyFieldType,
WireFormatLite::FieldType kValueFieldType>
struct MapEntry<Derived, Key, Value, kKeyFieldType,
kValueFieldType>::_Internal {
struct MapEntry<Key, Value, kKeyFieldType, kValueFieldType>::_Internal {
static constexpr ::int32_t kHasBitsOffset =
8 * PROTOBUF_FIELD_OFFSET(MapEntry, _impl_._has_bits_);
};

@ -26,7 +26,6 @@
#include "google/protobuf/generated_message_util.h"
#include "google/protobuf/internal_visibility.h"
#include "google/protobuf/map.h"
#include "google/protobuf/map_entry.h"
#include "google/protobuf/map_field_lite.h"
#include "google/protobuf/map_type_handler.h"
#include "google/protobuf/message.h"
@ -656,9 +655,6 @@ class MapField final : public TypeDefinedMapFieldBase<Key, T> {
typedef MapTypeHandler<kKeyFieldType_, Key> KeyTypeHandler;
typedef MapTypeHandler<kValueFieldType_, T> ValueTypeHandler;
// Define message type for internal repeated field.
typedef Derived EntryType;
public:
typedef Map<Key, T> MapType;
static constexpr WireFormatLite::FieldType kKeyFieldType = kKeyFieldType_;
@ -678,12 +674,6 @@ class MapField final : public TypeDefinedMapFieldBase<Key, T> {
this->MergeFromImpl(*this, from);
}
// Used in the implementation of parsing. Caller should take the ownership iff
// arena_ is nullptr.
EntryType* NewEntry() const {
return Arena::Create<EntryType>(this->arena());
}
private:
typedef void InternalArenaConstructable_;
typedef void DestructorSkippable_;
@ -712,14 +702,6 @@ bool AllAreInitialized(const TypeDefinedMapFieldBase<Key, T>& field) {
return true;
}
template <typename T, typename Key, typename Value,
WireFormatLite::FieldType kKeyFieldType,
WireFormatLite::FieldType kValueFieldType>
struct MapEntryToMapField<
MapEntry<T, Key, Value, kKeyFieldType, kValueFieldType>> {
typedef MapField<T, Key, Value, kKeyFieldType, kValueFieldType> MapFieldType;
};
class PROTOBUF_EXPORT DynamicMapField final
: public TypeDefinedMapFieldBase<MapKey, MapValueRef> {
public:

@ -2322,7 +2322,7 @@ TEST_F(MapFieldReflectionTest, UninitializedEntry) {
}
class MyMapEntry
: public internal::MapEntry<MyMapEntry, ::int32_t, ::int32_t,
: public internal::MapEntry<::int32_t, ::int32_t,
internal::WireFormatLite::TYPE_INT32,
internal::WireFormatLite::TYPE_INT32> {
public:

Loading…
Cancel
Save