From 8289ca4924391c58bb7cbc618dc9eaefd1e77d8c Mon Sep 17 00:00:00 2001 From: Denis Levchenko Date: Thu, 29 Oct 2020 14:33:26 +0500 Subject: [PATCH] More code style fixes --- routing/geometry.cpp | 30 +++++++++--------------------- routing/geometry.hpp | 9 +++++++-- routing/index_graph_loader.cpp | 1 - routing/index_graph_loader.hpp | 1 - 4 files changed, 16 insertions(+), 25 deletions(-) diff --git a/routing/geometry.cpp b/routing/geometry.cpp index fa287e2053..de50790bd6 100644 --- a/routing/geometry.cpp +++ b/routing/geometry.cpp @@ -23,9 +23,6 @@ using namespace std; namespace { -// @TODO(bykoianko) Consider setting cache size based on available memory. -// Maximum road geometry cache size in items. -size_t constexpr kRoadsCacheSize = 5000; double CalcFerryDurationHours(string const & durationHours, double roadLenKm) { @@ -41,7 +38,8 @@ double CalcFerryDurationHours(string const & durationHours, double roadLenKm) CHECK(strings::to_double(durationHours.c_str(), durationH), (durationHours)); // See: https://confluence.mail.ru/download/attachments/249123157/image2019-8-22_16-15-53.png - // Shortly: we drop some points: (x: lengthKm, y: durationH), that are upper or lower these two lines. + // Shortly: we drop some points: (x: lengthKm, y: durationH), that are upper or lower these two + // lines. double constexpr kUpperBoundIntercept = 4.0; double constexpr kUpperBoundSlope = 0.037; if (kUpperBoundIntercept + kUpperBoundSlope * roadLenKm - durationH < 0) @@ -60,8 +58,8 @@ class GeometryLoaderImpl final : public GeometryLoader { public: GeometryLoaderImpl(DataSource const & dataSource, MwmSet::MwmHandle const & handle, - shared_ptr vehicleModel, - AttrLoader attrLoader, bool loadAltitudes); + shared_ptr vehicleModel, AttrLoader attrLoader, + bool loadAltitudes); // GeometryLoader overrides: void Load(uint32_t featureId, RoadGeometry & road) override; @@ -253,18 +251,9 @@ double RoadGeometry::GetRoadLengthM() const } // Geometry ---------------------------------------------------------------------------------------- -Geometry::Geometry(unique_ptr loader) - : m_loader(move(loader)) - , m_featureIdToRoad(make_unique( - kRoadsCacheSize, - [this](uint32_t featureId, RoadGeometry & road) { m_loader->Load(featureId, road); })) -{ - CHECK(m_loader, ()); -} - Geometry::Geometry(unique_ptr loader, size_t roadsCacheSize) - : m_loader(move(loader)) - , m_featureIdToRoad(make_unique( + : m_loader(move(loader)) + , m_featureIdToRoad(make_unique( roadsCacheSize, [this](uint32_t featureId, RoadGeometry & road) { m_loader->Load(featureId, road); })) { @@ -283,8 +272,7 @@ RoadGeometry const & Geometry::GetRoad(uint32_t featureId) unique_ptr GeometryLoader::Create(DataSource const & dataSource, MwmSet::MwmHandle const & handle, shared_ptr vehicleModel, - AttrLoader && attrLoader, - bool loadAltitudes) + AttrLoader && attrLoader, bool loadAltitudes) { CHECK(handle.IsAlive(), ()); return make_unique(dataSource, handle, vehicleModel, move(attrLoader), @@ -292,8 +280,8 @@ unique_ptr GeometryLoader::Create(DataSource const & dataSource, } // static -unique_ptr GeometryLoader::CreateFromFile(string const & fileName, - shared_ptr vehicleModel) +unique_ptr GeometryLoader::CreateFromFile( + string const & fileName, shared_ptr vehicleModel) { return make_unique(fileName, vehicleModel); } diff --git a/routing/geometry.hpp b/routing/geometry.hpp index 2605543c30..a056e1070c 100644 --- a/routing/geometry.hpp +++ b/routing/geometry.hpp @@ -28,6 +28,10 @@ class DataSource; namespace routing { +// @TODO(bykoianko) Consider setting cache size based on available memory. +// Maximum road geometry cache size in items. +size_t constexpr kRoadsCacheSize = 5000; + class RoadGeometry final { public: @@ -135,8 +139,9 @@ class Geometry final { public: Geometry() = default; - explicit Geometry(std::unique_ptr loader); - Geometry(std::unique_ptr loader, size_t roadsCacheSize); + /// \brief Geometry constructor + /// \param roadsCacheSize in-memory geometry elements count limit + Geometry(std::unique_ptr loader, size_t roadsCacheSize = kRoadsCacheSize); /// \note The reference returned by the method is valid until the next call of GetRoad() /// of GetPoint() methods. diff --git a/routing/index_graph_loader.cpp b/routing/index_graph_loader.cpp index a8ca36e978..56f3e9177e 100644 --- a/routing/index_graph_loader.cpp +++ b/routing/index_graph_loader.cpp @@ -280,5 +280,4 @@ uint32_t DeserializeIndexGraphNumRoads(MwmValue const & mwmValue, VehicleType ve ReaderSource src(reader); return IndexGraphSerializer::DeserializeNumRoads(src, GetVehicleMask(vehicleType)); } - } // namespace routing diff --git a/routing/index_graph_loader.hpp b/routing/index_graph_loader.hpp index b459e43025..06dc271259 100644 --- a/routing/index_graph_loader.hpp +++ b/routing/index_graph_loader.hpp @@ -38,5 +38,4 @@ public: void DeserializeIndexGraph(MwmValue const & mwmValue, VehicleType vehicleType, IndexGraph & graph); uint32_t DeserializeIndexGraphNumRoads(MwmValue const & mwmValue, VehicleType vehicleType); - } // namespace routing