From 4918b10ae399932ba6c9a9b84e267819ebec40a8 Mon Sep 17 00:00:00 2001 From: tatiana-yan Date: Fri, 8 May 2020 14:56:30 +0300 Subject: [PATCH] [search] Fix per the PVS-Studio report. --- search/geocoder.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/search/geocoder.cpp b/search/geocoder.cpp index 5db712206b..84ffc021a0 100644 --- a/search/geocoder.cpp +++ b/search/geocoder.cpp @@ -1521,7 +1521,7 @@ void Geocoder::FindPaths(BaseContext & ctx) m_matcher->SetPostcodes(&m_postcodes.m_countryFeatures); auto isExactMatch = [](BaseContext const & context, IntersectionResult const & result) { - bool regionsChecked = false; + bool haveRegion = false; for (size_t i = 0; i < context.m_tokens.size(); ++i) { auto const tokenType = context.m_tokens[i]; @@ -1545,15 +1545,18 @@ void Geocoder::FindPaths(BaseContext & ctx) auto const isRegion = tokenType == BaseContext::TokenType::TOKEN_TYPE_STATE || tokenType == BaseContext::TokenType::TOKEN_TYPE_COUNTRY; - if (isRegion && !regionsChecked) + if (isRegion) + haveRegion = true; + } + if (haveRegion) + { + for (auto const & region : context.m_regions) { - for (auto const & region : context.m_regions) - { - if (!region->m_exactMatch) - return false; - } + if (!region->m_exactMatch) + return false; } } + return true; };