Skip to content

Commit 5eeacd2

Browse files
Optimize prepare data
Signed-off-by: Eugenio Collado <eugeniocollado@eprosima.com>
1 parent 430bfa4 commit 5eeacd2

1 file changed

Lines changed: 5 additions & 34 deletions

File tree

ddsenabler_participants/src/cpp/Writer.cpp

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,7 @@ void Writer::write_data(
178178
const fastdds::dds::DynamicType::_ref_type& dyn_type)
179179
{
180180
nlohmann::json json_data;
181-
if (!prepare_json_data_(msg, dyn_type, json_data))
182-
{
183-
return;
184-
}
185-
186-
//STORE DATA
187-
if (data_notification_callback_)
181+
if (data_notification_callback_ && prepare_json_data_(msg, dyn_type, json_data))
188182
{
189183
data_notification_callback_(
190184
msg.topic.topic_name().c_str(),
@@ -221,13 +215,7 @@ void Writer::write_service_reply_notification(
221215
const std::string& service_name)
222216
{
223217
nlohmann::json json_data;
224-
if (!prepare_json_data_(msg, dyn_type, json_data))
225-
{
226-
return;
227-
}
228-
229-
//STORE DATA
230-
if (service_reply_notification_callback_)
218+
if (service_reply_notification_callback_ && prepare_json_data_(msg, dyn_type, json_data))
231219
{
232220
service_reply_notification_callback_(
233221
service_name.c_str(),
@@ -245,13 +233,7 @@ void Writer::write_service_request_notification(
245233
const std::string& service_name)
246234
{
247235
nlohmann::json json_data;
248-
if (!prepare_json_data_(msg, dyn_type, json_data))
249-
{
250-
return;
251-
}
252-
253-
//STORE DATA
254-
if (service_request_notification_callback_)
236+
if (service_request_notification_callback_ && prepare_json_data_(msg, dyn_type, json_data))
255237
{
256238
service_request_notification_callback_(
257239
service_name.c_str(),
@@ -307,13 +289,7 @@ void Writer::write_action_result_notification(
307289
const std::string& action_name)
308290
{
309291
nlohmann::json json_data;
310-
if (!prepare_json_data_(msg, dyn_type, json_data))
311-
{
312-
return;
313-
}
314-
315-
//STORE DATA
316-
if (action_result_notification_callback_)
292+
if (action_result_notification_callback_ && prepare_json_data_(msg, dyn_type, json_data))
317293
{
318294
action_result_notification_callback_(
319295
action_name.c_str(),
@@ -330,14 +306,9 @@ void Writer::write_action_feedback_notification(
330306
const std::string& action_name)
331307
{
332308
nlohmann::json json_data;
333-
if (!prepare_json_data_(msg, dyn_type, json_data))
334-
{
335-
return;
336-
}
337-
338309
std::stringstream instanceHandle;
339310
instanceHandle << msg.instanceHandle;
340-
if (action_feedback_notification_callback_)
311+
if (action_feedback_notification_callback_ && prepare_json_data_(msg, dyn_type, json_data))
341312
{
342313
action_feedback_notification_callback_(
343314
action_name.c_str(),

0 commit comments

Comments
 (0)