@@ -1191,40 +1191,7 @@ const std::string& Reflection::GetStringReference(const Message& message,
1191
1191
1192
1192
1193
1193
void Reflection::SetString (Message* message, const FieldDescriptor* field,
1194
- const std::string& value) const {
1195
- USAGE_CHECK_ALL (SetString, SINGULAR, STRING);
1196
- if (field->is_extension ()) {
1197
- return MutableExtensionSet (message)->SetString (field->number (),
1198
- field->type (), value, field);
1199
- } else {
1200
- switch (field->options ().ctype ()) {
1201
- default : // TODO(kenton): Support other string reps.
1202
- case FieldOptions::STRING: {
1203
- if (IsInlined (field)) {
1204
- MutableField<InlinedStringField>(message, field)
1205
- ->SetNoArena (nullptr , value);
1206
- break ;
1207
- }
1208
-
1209
- const std::string* default_ptr =
1210
- &DefaultRaw<ArenaStringPtr>(field).Get ();
1211
- if (field->containing_oneof () && !HasOneofField (*message, field)) {
1212
- ClearOneof (message, field->containing_oneof ());
1213
- MutableField<ArenaStringPtr>(message, field)
1214
- ->UnsafeSetDefault (default_ptr);
1215
- }
1216
- MutableField<ArenaStringPtr>(message, field)
1217
- ->Mutable (default_ptr, GetArena (message))
1218
- ->assign (value);
1219
- break ;
1220
- }
1221
- }
1222
- }
1223
- }
1224
-
1225
-
1226
- void Reflection::SetString (Message* message, const FieldDescriptor* field,
1227
- std::string&& value) const {
1194
+ std::string value) const {
1228
1195
USAGE_CHECK_ALL (SetString, SINGULAR, STRING);
1229
1196
if (field->is_extension ()) {
1230
1197
return MutableExtensionSet (message)->SetString (field->number (),
@@ -1235,7 +1202,7 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
1235
1202
case FieldOptions::STRING: {
1236
1203
if (IsInlined (field)) {
1237
1204
MutableField<InlinedStringField>(message, field)
1238
- ->SetNoArena (nullptr , value);
1205
+ ->SetNoArena (nullptr , std::move ( value) );
1239
1206
break ;
1240
1207
}
1241
1208
@@ -1246,8 +1213,8 @@ void Reflection::SetString(Message* message, const FieldDescriptor* field,
1246
1213
MutableField<ArenaStringPtr>(message, field)
1247
1214
->UnsafeSetDefault (default_ptr);
1248
1215
}
1249
- *( MutableField<ArenaStringPtr>(message, field)
1250
- ->Mutable (default_ptr, GetArena (message))) = std::move (value);
1216
+ MutableField<ArenaStringPtr>(message, field)
1217
+ ->Mutable (default_ptr, GetArena (message))-> assign ( std::move (value) );
1251
1218
break ;
1252
1219
}
1253
1220
}
@@ -1288,25 +1255,7 @@ const std::string& Reflection::GetRepeatedStringReference(
1288
1255
1289
1256
void Reflection::SetRepeatedString (Message* message,
1290
1257
const FieldDescriptor* field, int index,
1291
- const std::string& value) const {
1292
- USAGE_CHECK_ALL (SetRepeatedString, REPEATED, STRING);
1293
- if (field->is_extension ()) {
1294
- MutableExtensionSet (message)->SetRepeatedString (field->number (), index ,
1295
- value);
1296
- } else {
1297
- switch (field->options ().ctype ()) {
1298
- default : // TODO(kenton): Support other string reps.
1299
- case FieldOptions::STRING:
1300
- *MutableRepeatedField<std::string>(message, field, index ) = value;
1301
- break ;
1302
- }
1303
- }
1304
- }
1305
-
1306
-
1307
- void Reflection::SetRepeatedString (Message* message,
1308
- const FieldDescriptor* field, int index,
1309
- std::string&& value) const {
1258
+ std::string value) const {
1310
1259
USAGE_CHECK_ALL (SetRepeatedString, REPEATED, STRING);
1311
1260
if (field->is_extension ()) {
1312
1261
MutableExtensionSet (message)->SetRepeatedString (field->number (), index ,
@@ -1315,31 +1264,15 @@ void Reflection::SetRepeatedString(Message* message,
1315
1264
switch (field->options ().ctype ()) {
1316
1265
default : // TODO(kenton): Support other string reps.
1317
1266
case FieldOptions::STRING:
1318
- *MutableRepeatedField<std::string>(message, field, index ) = std::move (value);
1319
- break ;
1320
- }
1321
- }
1322
- }
1323
-
1324
- void Reflection::AddString (Message* message, const FieldDescriptor* field,
1325
- const std::string& value) const {
1326
- USAGE_CHECK_ALL (AddString, REPEATED, STRING);
1327
- if (field->is_extension ()) {
1328
- MutableExtensionSet (message)->AddString (field->number (), field->type (),
1329
- value, field);
1330
- } else {
1331
- switch (field->options ().ctype ()) {
1332
- default : // TODO(kenton): Support other string reps.
1333
- case FieldOptions::STRING:
1334
- *AddField<std::string>(message, field) = value;
1267
+ MutableRepeatedField<std::string>(message, field, index )->assign (std::move (value));
1335
1268
break ;
1336
1269
}
1337
1270
}
1338
1271
}
1339
1272
1340
1273
1341
1274
void Reflection::AddString (Message* message, const FieldDescriptor* field,
1342
- std::string&& value) const {
1275
+ std::string value) const {
1343
1276
USAGE_CHECK_ALL (AddString, REPEATED, STRING);
1344
1277
if (field->is_extension ()) {
1345
1278
MutableExtensionSet (message)->AddString (field->number (), field->type (),
@@ -1348,12 +1281,13 @@ void Reflection::AddString(Message* message, const FieldDescriptor* field,
1348
1281
switch (field->options ().ctype ()) {
1349
1282
default : // TODO(kenton): Support other string reps.
1350
1283
case FieldOptions::STRING:
1351
- * AddField<std::string>(message, field) = std::move (value);
1284
+ AddField<std::string>(message, field)-> assign ( std::move (value) );
1352
1285
break ;
1353
1286
}
1354
1287
}
1355
1288
}
1356
1289
1290
+
1357
1291
// -------------------------------------------------------------------
1358
1292
1359
1293
const EnumValueDescriptor* Reflection::GetEnum (
0 commit comments