diff --git a/ecal/core/src/ecal_descgate.cpp b/ecal/core/src/ecal_descgate.cpp index 6f87e7ac62..786f28ea97 100644 --- a/ecal/core/src/ecal_descgate.cpp +++ b/ecal/core/src/ecal_descgate.cpp @@ -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 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 diff --git a/ecal/core/src/pubsub/ecal_pubgate.cpp b/ecal/core/src/pubsub/ecal_pubgate.cpp index 671b559210..8673594ab1 100644 --- a/ecal/core/src/pubsub/ecal_pubgate.cpp +++ b/ecal/core/src/pubsub/ecal_pubgate.cpp @@ -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) diff --git a/ecal/core/src/pubsub/ecal_subgate.cpp b/ecal/core/src/pubsub/ecal_subgate.cpp index f8ad72556d..fd1343d082 100644 --- a/ecal/core/src/pubsub/ecal_subgate.cpp +++ b/ecal/core/src/pubsub/ecal_subgate.cpp @@ -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) diff --git a/ecal/core/src/util/ecal_expmap.h b/ecal/core/src/util/ecal_expmap.h index 496ea80e72..bca21bf2bb 100644 --- a/ecal/core/src/util/ecal_expmap.h +++ b/ecal/core/src/util/ecal_expmap.h @@ -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 @@ -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