Skip to content

Commit

Permalink
Performance improvement for lower/upper bound (#1223)
Browse files Browse the repository at this point in the history
* Performance improvement for lower/upper bound

Changed updateQueries() to use member functions of `multiset` instead of `std::lower_bound` and `std::upper_bound`

* Fixed warnings for C++98

Changed the calls to lower/upper bounds so they dont use the "new" C++11 extended initializer lists.
  • Loading branch information
zivsha authored and dirk-thomas committed Dec 19, 2017
1 parent 2e0a18f commit bd51f97
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/rosbag_storage/src/view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,11 @@ void View::updateQueries(BagQuery* q) {
multiset<IndexEntry> 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<IndexEntry>::const_iterator begin = std::lower_bound(index.begin(), index.end(), q->query.getStartTime(), IndexEntryCompare());
std::multiset<IndexEntry>::const_iterator end = std::upper_bound(index.begin(), index.end(), q->query.getEndTime(), IndexEntryCompare());

IndexEntry start_time_lookup_entry = { q->query.getStartTime(), 0, 0 };
IndexEntry end_time_lookup_entry = { q->query.getEndTime() , 0, 0 };
std::multiset<IndexEntry>::const_iterator begin = index.lower_bound(start_time_lookup_entry);
std::multiset<IndexEntry>::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())
{
Expand Down

0 comments on commit bd51f97

Please sign in to comment.