From be77fe8de998ecff25138d1287a8831a0cb0d9f5 Mon Sep 17 00:00:00 2001 From: vng Date: Sat, 26 Jun 2021 09:00:22 +0300 Subject: [PATCH] Use move semantics for CountryFile initialization. Signed-off-by: vng --- platform/country_file.cpp | 2 +- platform/country_file.hpp | 5 ++++- routing/index_router.cpp | 7 +++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/platform/country_file.cpp b/platform/country_file.cpp index 13d0e9a132..e68777cb79 100644 --- a/platform/country_file.cpp +++ b/platform/country_file.cpp @@ -32,7 +32,7 @@ namespace platform { CountryFile::CountryFile() : m_mapSize(0) {} -CountryFile::CountryFile(string const & name) : m_name(name), m_mapSize(0) {} +CountryFile::CountryFile(string name) : m_name(std::move(name)), m_mapSize(0) {} string const & CountryFile::GetName() const { return m_name; } diff --git a/platform/country_file.hpp b/platform/country_file.hpp index 77750f888b..5799310bc6 100644 --- a/platform/country_file.hpp +++ b/platform/country_file.hpp @@ -16,7 +16,10 @@ class CountryFile { public: CountryFile(); - explicit CountryFile(std::string const & name); + explicit CountryFile(std::string name); + + /// \returns Empty (invalid) CountryFile. + bool IsEmpty() const { return m_name.empty(); } /// \returns file name without extensions. std::string const & GetName() const; diff --git a/routing/index_router.cpp b/routing/index_router.cpp index cab0fe7c1b..2ce86a065e 100644 --- a/routing/index_router.cpp +++ b/routing/index_router.cpp @@ -560,17 +560,16 @@ RouterResultCode IndexRouter::DoCalculateRoute(Checkpoints const & checkpoints, for (auto const & checkpoint : checkpoints.GetPoints()) { - string const countryName = m_countryFileFn(checkpoint); + auto const country = platform::CountryFile(m_countryFileFn(checkpoint)); - if (countryName.empty()) + if (country.IsEmpty()) { LOG(LWARNING, ("For point", mercator::ToLatLon(checkpoint), - "CountryInfoGetter returns an empty CountryFile(). It happens when checkpoint" + "CountryInfoGetter returns an empty CountryFile(). It happens when checkpoint " "is put at gaps between mwm.")); return RouterResultCode::InternalError; } - auto const country = platform::CountryFile(countryName); if (!m_dataSource.IsLoaded(country)) { route.AddAbsentCountry(country.GetName());