From 861eafd8094e4f8e100f322f8fc49a9ddafe8052 Mon Sep 17 00:00:00 2001 From: Ted Kern Date: Thu, 3 Oct 2019 23:48:49 +0200 Subject: [PATCH] rosbag_storage: Fixed unnecessary writing to map in write only mode #1742 (#1798) Signed-off-by: Ted Kern --- tools/rosbag_storage/include/rosbag/bag.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tools/rosbag_storage/include/rosbag/bag.h b/tools/rosbag_storage/include/rosbag/bag.h index b1ff159e42..d63273ecde 100644 --- a/tools/rosbag_storage/include/rosbag/bag.h +++ b/tools/rosbag_storage/include/rosbag/bag.h @@ -563,8 +563,11 @@ void Bag::doWrite(std::string const& topic, ros::Time const& time, T const& msg, std::multiset& chunk_connection_index = curr_chunk_connection_indexes_[connection_info->id]; chunk_connection_index.insert(chunk_connection_index.end(), index_entry); - std::multiset& connection_index = connection_indexes_[connection_info->id]; - connection_index.insert(connection_index.end(), index_entry); + + if (mode_ != BagMode::Write) { + std::multiset& connection_index = connection_indexes_[connection_info->id]; + connection_index.insert(connection_index.end(), index_entry); + } // Increment the connection count curr_chunk_info_.connection_counts[connection_info->id]++;