Added preallocation of vectors in RuleDrawer

This commit is contained in:
r.kuznetsov 2016-12-07 10:30:34 +03:00
parent 086c963b37
commit 46b80961c9

View file

@ -29,6 +29,8 @@
namespace
{
int constexpr kOutlineMinZoomLevel = 16;
// 10 11 12 13 14 15 16 17 18 19
vector<size_t> const kAverageSegmentsCount = { 10000, 5000, 10000, 5000, 2500, 5000, 2000, 1000, 500, 500 };
df::BaseApplyFeature::HotelData ExtractHotelData(FeatureType const & f)
{
@ -65,7 +67,12 @@ void ExtractTrafficGeometry(FeatureType const & f, df::RoadClass const & roadCla
static vector<uint8_t> directions = {traffic::TrafficInfo::RoadSegmentId::kForwardDirection,
traffic::TrafficInfo::RoadSegmentId::kReverseDirection};
auto & segments = geometry[f.GetID().m_mwmId];
segments.reserve(segments.size() + directions.size() * (polyline.GetSize() - 1));
int const index = zoomLevel - 10; // 10 - the first zoom level in kAverageSegmentsCount.
ASSERT_GREATER(index, 0, ());
ASSERT_LESS(index, kAverageSegmentsCount.size(), ());
segments.reserve(kAverageSegmentsCount[index]);
for (uint16_t segIndex = 0; segIndex + 1 < static_cast<uint16_t>(polyline.GetSize()); ++segIndex)
{
for (size_t dirIndex = 0; dirIndex < directions.size(); ++dirIndex)