@@ -477,7 +477,7 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
477
477
}
478
478
}
479
479
480
- static void SelectiveCopy (::google::protobuf::Message& protoTo, const ::google::protobuf::Message& protoFrom, const ::google::protobuf::RepeatedField<arc_i32 >& fields) {
480
+ static void SelectiveCopy (::google::protobuf::Message& protoTo, const ::google::protobuf::Message& protoFrom, const ::google::protobuf::RepeatedField<int >& fields) {
481
481
using namespace ::google::protobuf;
482
482
const Descriptor& descriptor = *protoTo.GetDescriptor ();
483
483
const Reflection& reflectionTo = *protoTo.GetReflection ();
@@ -490,24 +490,6 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
490
490
}
491
491
}
492
492
493
- template <typename TMessage>
494
- static ::google::protobuf::RepeatedField<arc_i32> GetDefaultFields (const TMessage& message) {
495
- using namespace ::google::protobuf;
496
- const Descriptor& descriptor = *message.GetDescriptor ();
497
- ::google::protobuf::RepeatedField<arc_i32> defaultFields;
498
- int fieldCount = descriptor.field_count ();
499
- for (int index = 0 ; index < fieldCount; ++index) {
500
- const FieldDescriptor* field = descriptor.field (index);
501
- const auto & options (field->options ());
502
- if (options.HasExtension (NKikimrWhiteboard::DefaultField)) {
503
- if (options.GetExtension (NKikimrWhiteboard::DefaultField)) {
504
- defaultFields.Add (field->number ());
505
- }
506
- }
507
- }
508
- return defaultFields;
509
- }
510
-
511
493
template <typename TMessage, typename TRequest>
512
494
static void Copy (TMessage& to, const TMessage& from, const TRequest& request) {
513
495
if (request.FieldsRequiredSize () > 0 ) {
@@ -517,8 +499,7 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
517
499
SelectiveCopy (to, from, request.GetFieldsRequired ());
518
500
}
519
501
} else {
520
- static auto defaultFields = GetDefaultFields (to);
521
- SelectiveCopy (to, from, defaultFields);
502
+ SelectiveCopy (to, from, GetDefaultWhiteboardFields<TMessage>());
522
503
}
523
504
}
524
505
@@ -1121,6 +1102,30 @@ class TNodeWhiteboardService : public TActorBootstrapped<TNodeWhiteboardService>
1121
1102
}
1122
1103
};
1123
1104
1105
+ template <typename TMessage>
1106
+ ::google::protobuf::RepeatedField<int > InitDefaultWhiteboardFields () {
1107
+ using namespace ::google::protobuf;
1108
+ const Descriptor& descriptor = *TMessage::GetDescriptor ();
1109
+ ::google::protobuf::RepeatedField<int > defaultFields;
1110
+ int fieldCount = descriptor.field_count ();
1111
+ for (int index = 0 ; index < fieldCount; ++index) {
1112
+ const FieldDescriptor* field = descriptor.field (index);
1113
+ const auto & options (field->options ());
1114
+ if (options.HasExtension (NKikimrWhiteboard::DefaultField)) {
1115
+ if (options.GetExtension (NKikimrWhiteboard::DefaultField)) {
1116
+ defaultFields.Add (field->number ());
1117
+ }
1118
+ }
1119
+ }
1120
+ return defaultFields;
1121
+ }
1122
+
1123
+ template <typename TMessage>
1124
+ ::google::protobuf::RepeatedField<int > GetDefaultWhiteboardFields () {
1125
+ static ::google::protobuf::RepeatedField<int > defaultFields = InitDefaultWhiteboardFields<TMessage>();
1126
+ return defaultFields;
1127
+ }
1128
+
1124
1129
IActor* CreateNodeWhiteboardService () {
1125
1130
return new TNodeWhiteboardService ();
1126
1131
}
0 commit comments