From 7e93fe636a917e2fb1cbac4946f7e59648659c15 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Mon, 3 Feb 2025 13:00:04 -0800 Subject: [PATCH] Clean up remnants of `const char*` -> `string_view` migration for return types. No behavior change, just removing the transitional code. PiperOrigin-RevId: 722766820 --- src/google/protobuf/descriptor.h | 26 ++++++++------------------ src/google/protobuf/port_def.inc | 2 -- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/src/google/protobuf/descriptor.h b/src/google/protobuf/descriptor.h index 3a73481308..806337e328 100644 --- a/src/google/protobuf/descriptor.h +++ b/src/google/protobuf/descriptor.h @@ -204,12 +204,6 @@ typedef absl::string_view DescriptorStringView; typedef const std::string& DescriptorStringView; #endif -#if defined(PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE_TYPENAME) -typedef absl::string_view DescriptorTypenameStringView; -#else -typedef const char* DescriptorTypenameStringView; -#endif - class FlatAllocator; class PROTOBUF_EXPORT LazyDescriptor { @@ -882,10 +876,10 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, Type type() const; // Declared type of this field. // Name of the declared type. - internal::DescriptorTypenameStringView type_name() const; + absl::string_view type_name() const; CppType cpp_type() const; // C++ type of this field. // Name of the C++ type. - internal::DescriptorTypenameStringView cpp_type_name() const; + absl::string_view cpp_type_name() const; Label label() const; // optional/required/repeated #ifndef SWIG @@ -1037,10 +1031,10 @@ class PROTOBUF_EXPORT FieldDescriptor : private internal::SymbolBase, static CppType TypeToCppType(Type type); // Helper method to get the name of a Type. - static internal::DescriptorTypenameStringView TypeName(Type type); + static absl::string_view TypeName(Type type); // Helper method to get the name of a CppType. - static internal::DescriptorTypenameStringView CppTypeName(CppType cpp_type); + static absl::string_view CppTypeName(CppType cpp_type); // Return true iff [packed = true] is valid for fields of this type. static inline bool IsTypePackable(Type field_type); @@ -2918,8 +2912,7 @@ inline int MethodDescriptor::index() const { return static_cast(this - service_->methods_); } -inline internal::DescriptorTypenameStringView FieldDescriptor::type_name() - const { +inline absl::string_view FieldDescriptor::type_name() const { return kTypeToName[type()]; } @@ -2927,8 +2920,7 @@ inline FieldDescriptor::CppType FieldDescriptor::cpp_type() const { return kTypeToCppTypeMap[type()]; } -inline internal::DescriptorTypenameStringView FieldDescriptor::cpp_type_name() - const { +inline absl::string_view FieldDescriptor::cpp_type_name() const { return kCppTypeToName[kTypeToCppTypeMap[type()]]; } @@ -2936,13 +2928,11 @@ inline FieldDescriptor::CppType FieldDescriptor::TypeToCppType(Type type) { return kTypeToCppTypeMap[type]; } -inline internal::DescriptorTypenameStringView FieldDescriptor::TypeName( - Type type) { +inline absl::string_view FieldDescriptor::TypeName(Type type) { return kTypeToName[type]; } -inline internal::DescriptorTypenameStringView FieldDescriptor::CppTypeName( - CppType cpp_type) { +inline absl::string_view FieldDescriptor::CppTypeName(CppType cpp_type) { return kCppTypeToName[cpp_type]; } diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc index 5eaed27112..35f49afb4b 100644 --- a/src/google/protobuf/port_def.inc +++ b/src/google/protobuf/port_def.inc @@ -155,8 +155,6 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), #endif #define PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE 1 -#define PROTOBUF_FUTURE_STRING_VIEW_RETURN_TYPE_TYPENAME 1 - #ifdef PROTOBUF_ALWAYS_INLINE #error PROTOBUF_ALWAYS_INLINE was previously defined #endif