Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] minor performance improvements #1742

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions ecal/core/src/ecal_descgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,20 @@ namespace eCAL
{
const auto topic_info_key = Registration::STopicId{ ConvertToEntityId(topic_id_), topic_name_ };

Registration::SQualityTopicInfo topic_quality_info;
topic_quality_info.info = topic_info_;
topic_quality_info.quality = topic_quality_;

// update topic info
bool new_topic_info(false);
{
const std::unique_lock<std::mutex> lock(topic_info_map_.mtx);
const auto iter = topic_info_map_.map.find(topic_info_key);
new_topic_info = iter == topic_info_map_.map.end();
topic_info_map_.map[topic_info_key] = topic_quality_info;
QualityTopicIdMap::iterator topic_info_quality_iter = topic_info_map_.map.find(topic_info_key);
new_topic_info = topic_info_quality_iter == topic_info_map_.map.end();

if (new_topic_info)
{
std::tie(topic_info_quality_iter, std::ignore) = topic_info_map_.map.emplace(topic_info_key, Registration::SQualityTopicInfo{});
}

topic_info_quality_iter->second.info = topic_info_;
topic_info_quality_iter->second.quality = topic_quality_;
}

// notify publisher / subscriber registration callbacks about new entity
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/pubsub/ecal_pubgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ namespace eCAL

// TODO: Substitute ProducerInfo type
const auto& subscription_info = ecal_sample_.identifier;
const SDataTypeInformation topic_information = ecal_topic.tdatatype;
const SDataTypeInformation& topic_information = ecal_topic.tdatatype;

CDataWriter::SLayerStates layer_states;
for (const auto& layer : ecal_topic.tlayer)
Expand Down
2 changes: 1 addition & 1 deletion ecal/core/src/pubsub/ecal_subgate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ namespace eCAL
if (topic_name.empty()) return;

const auto& publication_info = ecal_sample_.identifier;
const SDataTypeInformation topic_information = ecal_topic.tdatatype;
const SDataTypeInformation& topic_information = ecal_topic.tdatatype;

CDataReader::SLayerStates layer_states;
for (const auto& layer : ecal_topic.tlayer)
Expand Down
18 changes: 7 additions & 11 deletions ecal/core/src/util/ecal_expmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ namespace eCAL
// We do have it:
// Update access record by moving
// accessed key to back of list
update_timestamp(k);
update_timestamp(it);
}

// Return the retrieved value
Expand Down Expand Up @@ -341,19 +341,15 @@ namespace eCAL
private:

// Maybe pass the iterator instead of the key? or at least only get k once
void update_timestamp(const Key& k)
void update_timestamp(const typename InternalMapType::iterator& it_in_map)
{
auto it_in_map = _internal_map.find(k);
if (it_in_map != _internal_map.end())
{
auto& it_in_list = it_in_map->second.timestamp_list_iterator;
auto& it_in_list = it_in_map->second.timestamp_list_iterator;

// move the element to the end of the list
_access_timestamps_list.splice(_access_timestamps_list.end(), _access_timestamps_list, it_in_list);
// move the element to the end of the list
_access_timestamps_list.splice(_access_timestamps_list.end(), _access_timestamps_list, it_in_list);

// update the timestamp
it_in_list->timestamp = get_curr_time();
}
// update the timestamp
it_in_list->timestamp = get_curr_time();
}

// Record a fresh key-value pair in the cache
Expand Down
Loading