From f06d3aaa3c2a32f98478074dd2a3589a88c9df47 Mon Sep 17 00:00:00 2001 From: Ziv Shahaf Date: Wed, 8 Nov 2017 19:33:47 +0200 Subject: [PATCH 1/2] Performance improvement for lower/upper bound Changed updateQueries() to use member functions of `multiset` instead of `std::lower_bound` and `std::upper_bound` --- tools/rosbag_storage/src/view.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/rosbag_storage/src/view.cpp b/tools/rosbag_storage/src/view.cpp index dbb1e72478..d5926b5ad7 100644 --- a/tools/rosbag_storage/src/view.cpp +++ b/tools/rosbag_storage/src/view.cpp @@ -282,9 +282,9 @@ void View::updateQueries(BagQuery* q) { // lower_bound/upper_bound do a binary search to find the appropriate range of Index Entries given our time range - std::multiset::const_iterator begin = std::lower_bound(index.begin(), index.end(), q->query.getStartTime(), IndexEntryCompare()); - std::multiset::const_iterator end = std::upper_bound(index.begin(), index.end(), q->query.getEndTime(), IndexEntryCompare()); - + std::multiset::const_iterator begin = index.lower_bound({ q->query.getStartTime(), 0, 0 }); + std::multiset::const_iterator end = index.upper_bound({ q->query.getEndTime() , 0, 0 }); + // Make sure we are at the right beginning while (begin != index.begin() && begin->time >= q->query.getStartTime()) { From 9775a765e3ac5dc66b174b731f4cc91adf229500 Mon Sep 17 00:00:00 2001 From: Ziv Shahaf Date: Thu, 9 Nov 2017 00:08:25 +0200 Subject: [PATCH 2/2] Fixed warnings for C++98 Changed the calls to lower/upper bounds so they dont use the "new" C++11 extended initializer lists. --- tools/rosbag_storage/src/view.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/rosbag_storage/src/view.cpp b/tools/rosbag_storage/src/view.cpp index d5926b5ad7..dd9fc4842b 100644 --- a/tools/rosbag_storage/src/view.cpp +++ b/tools/rosbag_storage/src/view.cpp @@ -281,9 +281,10 @@ void View::updateQueries(BagQuery* q) { multiset const& index = j->second; // lower_bound/upper_bound do a binary search to find the appropriate range of Index Entries given our time range - - std::multiset::const_iterator begin = index.lower_bound({ q->query.getStartTime(), 0, 0 }); - std::multiset::const_iterator end = index.upper_bound({ q->query.getEndTime() , 0, 0 }); + IndexEntry start_time_lookup_entry = { q->query.getStartTime(), 0, 0 }; + IndexEntry end_time_lookup_entry = { q->query.getEndTime() , 0, 0 }; + std::multiset::const_iterator begin = index.lower_bound(start_time_lookup_entry); + std::multiset::const_iterator end = index.upper_bound(end_time_lookup_entry); // Make sure we are at the right beginning while (begin != index.begin() && begin->time >= q->query.getStartTime())