Skip to content

Commit

Permalink
[MonGUI] minor performance improvements. (#1746)
Browse files Browse the repository at this point in the history
- Do not get a topic type / encoding from utils if this topic has not set them. 
- Avoid copies
  • Loading branch information
KerstinKeller authored Sep 27, 2024
1 parent e2aec45 commit 1e48373
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 40 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -508,7 +508,7 @@ void EcalmonTreeWidget::loadGuiSettings(const QString& group)

QVector<int> group_by_columns;
int auto_expand = 0;
for (auto column_variant : settings.value("group_by_columns").toList())
for (const auto& column_variant : settings.value("group_by_columns").toList())
{
int column = column_variant.toInt();
if ((column >= 0) && (column < group_tree_model_->columnCount()))
Expand Down
5 changes: 3 additions & 2 deletions app/mon/mon_gui/src/widgets/models/host_tree_item.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -167,8 +167,9 @@ void HostTreeItem::update(const eCAL::pb::Monitoring& monitoring_pb)
data_received_bytes_ = 0;

// Fill variables with accumulated data
for (auto topic : monitoring_pb.topics())
for (int i = 0; i <monitoring_pb.topics_size(); ++i)
{
const auto& topic = monitoring_pb.topics(i);
if (QString(topic.hname().c_str()).compare(host_name_, Qt::CaseSensitivity::CaseInsensitive) == 0)
{
QString direction = topic.direction().c_str();
Expand Down
36 changes: 2 additions & 34 deletions app/mon/mon_gui/src/widgets/models/topic_tree_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,11 @@ QVariant TopicTreeItem::data(Columns column, Qt::ItemDataRole role) const
}
else if (column == Columns::TENCODING)
{
// When the monitor didn't tell us the topic encoding, we ask eCAL::Util instead
// Why this logic only for type, not descriptor? (and thus encoding?)
const std::string monitor_topic_encoding = topic_.tdatatype().encoding();
if (!monitor_topic_encoding.empty())
{
return monitor_topic_encoding.c_str();
}
else
{
const std::string monitor_topic_name = topic_.tname();
if (!monitor_topic_name.empty())
{
eCAL::SDataTypeInformation topic_info;
eCAL::Registration::GetTopicDataTypeInformation(monitor_topic_name, topic_info);
return topic_info.encoding.c_str();
}
}
return topic_.tdatatype().encoding().c_str();
}
else if (column == Columns::TTYPE)
{
// When the monitor didn't tell us the topic type, we ask eCAL::Util instead
// Why this logic only for type, not descriptor? (and thus encoding?)
const std::string monitor_topic_type = topic_.tdatatype().name();
if (!monitor_topic_type.empty())
{
return monitor_topic_type.c_str();
}
else
{
const std::string monitor_topic_name = topic_.tname();
if (!monitor_topic_name.empty())
{
eCAL::SDataTypeInformation topic_info;
eCAL::Registration::GetTopicDataTypeInformation(monitor_topic_name, topic_info);
return topic_info.name.c_str();
}
}
return topic_.tdatatype().name().c_str();
}
else if (column == Columns::TDESC)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* ========================= eCAL LICENSE =================================
*
* Copyright (C) 2016 - 2019 Continental Corporation
* Copyright (C) 2016 - 2024 Continental Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -221,6 +221,6 @@ void VisualisationWidget::checkForMorePublishersWithSameTopic(const eCAL::pb::Mo
}
}
ui_.textEdit->clear();
for (auto publisher : publishers)
for (const auto& publisher : publishers)
ui_.textEdit->append(publisher);
}

0 comments on commit 1e48373

Please sign in to comment.