Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortatiana-yan <tatiana.kondakova@gmail.com>2021-02-25 15:10:38 +0300
committerOlga Khlopkova <mesozoic.drones@gmail.com>2021-02-25 15:20:49 +0300
commite1c07f8bd92e76f625e6abe03a78143b1e7c8a5a (patch)
tree04f7877f17dca29d8261e2cca39c7b039b82a47e /transit
parent5474f1a4271c1b7e0755661d212803837506f195 (diff)
Review fixes
Diffstat (limited to 'transit')
-rw-r--r--transit/world_feed/world_feed.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/transit/world_feed/world_feed.cpp b/transit/world_feed/world_feed.cpp
index c6dbd61c66..114e95da9d 100644
--- a/transit/world_feed/world_feed.cpp
+++ b/transit/world_feed/world_feed.cpp
@@ -224,23 +224,15 @@ std::optional<size_t> GetStopIndex(
auto it = stopIndexes.find(id);
CHECK(it != stopIndexes.end(), (id));
- auto stops = it->second;
- std::sort(stops.begin(), stops.end());
-
- if (direction == Direction::Forward)
+ std::optional<size_t> bestIdx;
+ for (auto const & index : it->second)
{
- auto const stopIt =
- std::find_if(stops.begin(), stops.end(), [&](size_t index) { return index >= fromIndex; });
- if (stopIt == stops.end())
- return {};
- return *stopIt;
+ if (direction == Direction::Forward && index >= fromIndex && (!bestIdx || index < bestIdx))
+ bestIdx = index;
+ if (direction == Direction::Backward && index <= fromIndex && (!bestIdx || index > bestIdx))
+ bestIdx = index;
}
-
- auto const stopIt =
- std::find_if(stops.rbegin(), stops.rend(), [&](size_t index) { return index <= fromIndex; });
- if (stopIt == stops.rend())
- return {};
- return *stopIt;
+ return bestIdx;
}
std::optional<std::pair<StopOnShape, StopOnShape>> GetStopPairOnShape(