From 68e3d3207c13181f53281b73c66a6d752087e2b3 Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Mon, 15 Feb 2016 14:53:50 +0300 Subject: [PATCH] [new downloader] Review fixes. --- storage/country.hpp | 6 +++--- storage/storage.cpp | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/storage/country.hpp b/storage/country.hpp index 1c0e6ecf0d..27716d73f4 100644 --- a/storage/country.hpp +++ b/storage/country.hpp @@ -25,10 +25,10 @@ namespace storage { using TMapping = map; -/// This class keep all the information about a country in countre tree (TCountriesContainer). +/// This class keeps all the information about a country in countre tree (TCountriesContainer). /// It is guaranteed that every node represent a unique region has a unique |m_name| in country tree. -/// If several nodes have the same |m_name| they represents the same region. -/// It could happend in case of disputed territories. +/// If several nodes have the same |m_name| they represent the same region. +/// It happends in case of disputed territories. /// That means that /// * if several leaf nodes have the same |m_name| one mwm file corresponds /// to all of them diff --git a/storage/storage.cpp b/storage/storage.cpp index e00c65ef80..f0e4e4322d 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -76,6 +76,14 @@ void DeleteFromDiskWithIndexes(LocalCountryFile const & localFile, MapOptions op DeleteCountryIndexes(localFile); localFile.DeleteFromDisk(options); } + +TCountriesContainer const & LeafNodeFromCountryId(TCountriesContainer const & root, + TCountryId const & countryId) +{ + SimpleTree const * node = root.FindFirstLeaf(Country(countryId)); + CHECK(node, ("Node with id =", countryId, "not found in country tree as a leaf.")); + return *node; +} } // namespace bool HasCountryId(TCountriesVec const & sortedCountryIds, TCountryId const & countryId) @@ -241,17 +249,9 @@ size_t Storage::GetDownloadedFilesCount() const return m_localFiles.size(); } -TCountriesContainer const & NodeFromCountryId(TCountriesContainer const & root, - TCountryId const & countryId) -{ - SimpleTree const * node = root.FindFirstLeaf(Country(countryId)); - CHECK(node, ("Node with id =", countryId, "not found in country tree as a leaf.")); - return *node; -} - Country const & Storage::CountryLeafByCountryId(TCountryId const & countryId) const { - return NodeFromCountryId(m_countries, countryId).Value(); + return LeafNodeFromCountryId(m_countries, countryId).Value(); } Country const & Storage::CountryByCountryId(TCountryId const & countryId) const @@ -278,12 +278,12 @@ void Storage::GetGroupAndCountry(TCountryId const & countryId, string & group, s size_t Storage::CountriesCount(TCountryId const & countryId) const { - return NodeFromCountryId(m_countries, countryId).ChildrenCount(); + return LeafNodeFromCountryId(m_countries, countryId).ChildrenCount(); } string const & Storage::CountryName(TCountryId const & countryId) const { - return NodeFromCountryId(m_countries, countryId).Value().Name(); + return LeafNodeFromCountryId(m_countries, countryId).Value().Name(); } bool Storage::IsCoutryIdInCountryTree(TCountryId const & countryId) const @@ -1160,6 +1160,7 @@ void Storage::GetNodeAttrs(TCountryId const & countryId, NodeAttrs & nodeAttrs) nodeAttrs.m_nodeLocalName = m_countryNameGetter(countryId); nodeAttrs.m_parentInfo.clear(); + nodeAttrs.m_parentInfo.reserve(nodes.size()); for (auto const & n : nodes) { Country const & nValue = n->Value();