From 1797673d046ef4a7add3fe253d87bf9e56113d76 Mon Sep 17 00:00:00 2001 From: Sergey Yershov Date: Mon, 31 Aug 2015 18:14:55 +0300 Subject: [PATCH] Review fix --- generator/generator_tests/osm_type_test.cpp | 10 +++++----- generator/intermediate_data.hpp | 19 +++++++++---------- generator/intermediate_elements.hpp | 1 + generator/osm_translator.hpp | 3 ++- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/generator/generator_tests/osm_type_test.cpp b/generator/generator_tests/osm_type_test.cpp index c2ee2c23fa..0a226b1b62 100644 --- a/generator/generator_tests/osm_type_test.cpp +++ b/generator/generator_tests/osm_type_test.cpp @@ -655,7 +655,7 @@ UNIT_TEST(OsmType_Subway) { "transport", "subway" }, }; - XMLElement e; + OsmElement e; FillXmlElement(arr, ARRAY_SIZE(arr), &e); FeatureParams params; @@ -674,7 +674,7 @@ UNIT_TEST(OsmType_Subway) { "route", "subway" }, }; - XMLElement e; + OsmElement e; FillXmlElement(arr, ARRAY_SIZE(arr), &e); FeatureParams params; @@ -694,7 +694,7 @@ UNIT_TEST(OsmType_Subway) { "station", "light_rail" }, }; - XMLElement e; + OsmElement e; FillXmlElement(arr, ARRAY_SIZE(arr), &e); FeatureParams params; @@ -716,7 +716,7 @@ UNIT_TEST(OsmType_Subway) { "transport", "monorail" }, }; - XMLElement e; + OsmElement e; FillXmlElement(arr, ARRAY_SIZE(arr), &e); FeatureParams params; @@ -735,7 +735,7 @@ UNIT_TEST(OsmType_Subway) { "railway", "station" }, }; - XMLElement e; + OsmElement e; FillXmlElement(arr, ARRAY_SIZE(arr), &e); FeatureParams params; diff --git a/generator/intermediate_data.hpp b/generator/intermediate_data.hpp index 41b1cc789c..a82ae6c162 100644 --- a/generator/intermediate_data.hpp +++ b/generator/intermediate_data.hpp @@ -39,7 +39,6 @@ class IndexFile TContainer m_elements; TFile m_file; - uint64_t m_fileSize = 0; static size_t constexpr kFlushCount = 1024; @@ -60,7 +59,7 @@ class IndexFile } public: - IndexFile(string const & name) : m_file(name.c_str()) {} + explicit IndexFile(string const & name) : m_file(name.c_str()) {} string GetFileName() const { return m_file.GetName(); } @@ -76,23 +75,23 @@ public: void ReadAll() { m_elements.clear(); - m_fileSize = m_file.Size(); - if (m_fileSize == 0) + size_t fileSize = m_file.Size(); + if (fileSize == 0) return; LOG_SHORT(LINFO, ("Offsets reading is started for file ", GetFileName())); - CHECK_EQUAL(0, m_fileSize % sizeof(TElement), ("Damaged file.")); + CHECK_EQUAL(0, fileSize % sizeof(TElement), ("Damaged file.")); try { - m_elements.resize(CheckedCast(m_fileSize / sizeof(TElement))); + m_elements.resize(CheckedCast(fileSize / sizeof(TElement))); } catch (exception const &) // bad_alloc { LOG(LCRITICAL, ("Insufficient memory for required offset map")); } - m_file.Read(0, &m_elements[0], CheckedCast(m_fileSize)); + m_file.Read(0, &m_elements[0], CheckedCast(fileSize)); sort(m_elements.begin(), m_elements.end(), ElementComparator()); @@ -258,7 +257,7 @@ class RawFilePointStorage : public PointStorage constexpr static double const kValueOrder = 1E+7; public: - RawFilePointStorage(string const & name) : m_file(name) {} + explicit RawFilePointStorage(string const & name) : m_file(name) {} template typename enable_if::type AddPoint(uint64_t id, double lat, double lng) @@ -307,7 +306,7 @@ class RawMemPointStorage : public PointStorage vector m_data; public: - RawMemPointStorage(string const & name) : m_file(name), m_data((size_t)0xFFFFFFFF) + explicit RawMemPointStorage(string const & name) : m_file(name), m_data((size_t)0xFFFFFFFF) { InitStorage(); } @@ -373,7 +372,7 @@ class MapFilePointStorage : public PointStorage constexpr static double const kValueOrder = 1E+7; public: - MapFilePointStorage(string const & name) : m_file(name + ".short") { InitStorage(); } + explicit MapFilePointStorage(string const & name) : m_file(name + ".short") { InitStorage(); } template typename enable_if::type InitStorage() {} diff --git a/generator/intermediate_elements.hpp b/generator/intermediate_elements.hpp index 3164ffdce6..9e90560807 100644 --- a/generator/intermediate_elements.hpp +++ b/generator/intermediate_elements.hpp @@ -41,6 +41,7 @@ struct WayElement template void ForEachPointOrdered(uint64_t start, ToDo & toDo) { + ASSERT(!nodes.empty(), ()); if (start == nodes.front()) for_each(nodes.begin(), nodes.end(), ref(toDo)); else diff --git a/generator/osm_translator.hpp b/generator/osm_translator.hpp index 7bc1835030..ecb5a92b00 100644 --- a/generator/osm_translator.hpp +++ b/generator/osm_translator.hpp @@ -109,7 +109,7 @@ class OsmToFeatureTranslator public: RelationTagsBase() : m_cache(14) {} - void Reset(uint64_t fID, XMLElement * p) + void Reset(uint64_t fID, OsmElement * p) { m_featureID = fID; m_current = p; @@ -227,6 +227,7 @@ class OsmToFeatureTranslator TBase::m_current->AddTag(p.first, p.second); } } + } m_wayRelations; bool ParseType(OsmElement * p, FeatureParams & params) {