From 6596abee0da252a362b98ff64634f5bdb57be75f Mon Sep 17 00:00:00 2001 From: Sergey Yershov Date: Thu, 23 Apr 2015 18:46:44 +0300 Subject: [PATCH] Review fix --- search/feature_offset_match.hpp | 12 +++++++++--- search/house_detector.cpp | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp index 8369ca2b85..4b8c128a74 100644 --- a/search/feature_offset_match.hpp +++ b/search/feature_offset_match.hpp @@ -47,7 +47,10 @@ TrieIterator * MoveTrieIteratorToString(TrieIterator const & trieRoot, { bool bMatched = false; - for (uint32_t i = 0; i < pIter->m_edge.size(); ++i) + ASSERT_LESS(pIter->m_edge.size(), std::numeric_limits::max(), ()); + uint32_t const edgeCount = static_cast(pIter->m_edge.size()); + + for (uint32_t i = 0; i < edgeCount; ++i) { size_t const szEdge = pIter->m_edge[i].m_str.size(); @@ -159,10 +162,13 @@ void PrefixMatchInTrie(TrieIterator const & trieRoot, unique_ptr const pIter(trieQueue.back()); trieQueue.pop_back(); - for (size_t i = 0; i < pIter->m_value.size(); ++i) + ASSERT_LESS(pIter->m_edge.size(), std::numeric_limits::max(), ()); + uint32_t const edgeCount = static_cast(pIter->m_edge.size()); + + for (uint32_t i = 0; i < edgeCount; ++i) f(pIter->m_value[i]); - for (uint32_t i = 0; i < pIter->m_edge.size(); ++i) + for (uint32_t i = 0; i < edgeCount; ++i) trieQueue.push_back(pIter->GoToEdge(i)); } } diff --git a/search/house_detector.cpp b/search/house_detector.cpp index 3a3adc25f4..08eb0be9ec 100644 --- a/search/house_detector.cpp +++ b/search/house_detector.cpp @@ -153,7 +153,7 @@ ParsedNumber::ParsedNumber(string const & number, bool american) : m_fullN(numbe size_t start = curr; try { - int const x = stoi(number.substr(curr), &curr, 10); + int const x = stoi(number.substr(start), &curr, 10); curr += start; m_endN = x; ASSERT_GREATER_OR_EQUAL(m_endN, 0, (number)); @@ -161,7 +161,7 @@ ParsedNumber::ParsedNumber(string const & number, bool american) : m_fullN(numbe } catch (exception & e) { - // Expected case, we need to do nothig + // Expected case - stoi haven't parsed anything. } } curr = 0;