@@ -130,7 +130,6 @@ FieldGeneratorBase::FieldGeneratorBase(const FieldDescriptor* field,
130130 break ;
131131 case FieldDescriptor::CPPTYPE_STRING:
132132 is_string_ = true ;
133- string_type_ = field->options ().ctype ();
134133 is_inlined_ = IsStringInlined (field, options);
135134 is_bytes_ = field->type () == FieldDescriptor::TYPE_BYTES;
136135 has_default_constexpr_constructor_ = is_repeated_or_map;
@@ -229,40 +228,6 @@ void FieldGeneratorBase::GenerateCopyConstructorCode(io::Printer* p) const {
229228}
230229
231230namespace {
232- // Use internal types instead of ctype or string_type.
233- enum class StringType {
234- kView ,
235- kString ,
236- kCord ,
237- kStringPiece ,
238- };
239-
240- StringType GetStringType (const FieldDescriptor& field) {
241- ABSL_CHECK_EQ (field.cpp_type (), FieldDescriptor::CPPTYPE_STRING);
242-
243- if (field.options ().has_ctype ()) {
244- switch (field.options ().ctype ()) {
245- case FieldOptions::CORD:
246- return StringType::kCord ;
247- case FieldOptions::STRING_PIECE:
248- return StringType::kStringPiece ;
249- default :
250- return StringType::kString ;
251- }
252- }
253-
254- const pb::CppFeatures& cpp_features =
255- CppGenerator::GetResolvedSourceFeatures (field).GetExtension (::pb::cpp);
256- switch (cpp_features.string_type ()) {
257- case pb::CppFeatures::CORD:
258- return StringType::kCord ;
259- case pb::CppFeatures::VIEW:
260- return StringType::kView ;
261- default :
262- return StringType::kString ;
263- }
264- }
265-
266231std::unique_ptr<FieldGeneratorBase> MakeGenerator (const FieldDescriptor* field,
267232 const Options& options,
268233 MessageSCCAnalyzer* scc) {
@@ -279,7 +244,7 @@ std::unique_ptr<FieldGeneratorBase> MakeGenerator(const FieldDescriptor* field,
279244 case FieldDescriptor::CPPTYPE_MESSAGE:
280245 return MakeRepeatedMessageGenerator (field, options, scc);
281246 case FieldDescriptor::CPPTYPE_STRING: {
282- if (GetStringType (* field) == StringType ::kView ) {
247+ if (field-> cpp_string_type ( ) == FieldDescriptor::CppStringType ::kView ) {
283248 return MakeRepeatedStringViewGenerator (field, options, scc);
284249 } else {
285250 return MakeRepeatedStringGenerator (field, options, scc);
@@ -303,10 +268,10 @@ std::unique_ptr<FieldGeneratorBase> MakeGenerator(const FieldDescriptor* field,
303268 case FieldDescriptor::CPPTYPE_ENUM:
304269 return MakeSinguarEnumGenerator (field, options, scc);
305270 case FieldDescriptor::CPPTYPE_STRING: {
306- switch (GetStringType (* field)) {
307- case StringType ::kView :
271+ switch (field-> cpp_string_type ( )) {
272+ case FieldDescriptor::CppStringType ::kView :
308273 return MakeSingularStringViewGenerator (field, options, scc);
309- case StringType ::kCord :
274+ case FieldDescriptor::CppStringType ::kCord :
310275 if (field->type () == FieldDescriptor::TYPE_BYTES) {
311276 if (field->real_containing_oneof ()) {
312277 return MakeOneofCordGenerator (field, options, scc);
0 commit comments