Replace some code with std::find algorithm.

This commit is contained in:
vng 2012-02-16 15:31:23 +03:00 committed by Alex Zolotarev
parent fe18fbfd85
commit 7544c46f04
3 changed files with 6 additions and 18 deletions

View file

@ -81,11 +81,7 @@ namespace feature
inline bool Has(uint32_t t) const
{
for (size_t i = 0; i < m_size; ++i)
if (t == m_types[i])
return true;
return false;
return find(m_types, m_types + m_size, t);
}
//@}

View file

@ -396,10 +396,7 @@ bool UsePopulationRank(uint32_t type)
bool IsMyType(uint32_t t) const
{
for (size_t i = 0; i < ARRAY_SIZE(m_types); ++i)
if (t == m_types[i])
return true;
return false;
return find(m_types, m_types + ARRAY_SIZE(m_types), t);
}
};

View file

@ -241,27 +241,22 @@ namespace
class IsLinearChecker
{
static size_t const m_count = 2;
uint8_t m_index[m_count];
uint8_t m_index[2];
public:
IsLinearChecker()
{
char const * arr[] = { "highway", "waterway" };
STATIC_ASSERT ( ARRAY_SIZE(arr) == m_count );
STATIC_ASSERT ( ARRAY_SIZE(arr) == ARRAY_SIZE(m_index) );
ClassifObject const * c = classif().GetRoot();
for (size_t i = 0; i < m_count; ++i)
for (size_t i = 0; i < ARRAY_SIZE(m_index); ++i)
m_index[i] = static_cast<uint8_t>(c->BinaryFind(arr[i]).GetIndex());
}
bool IsMy(uint8_t ind) const
{
for (size_t i = 0; i < m_count; ++i)
if (ind == m_index[i])
return true;
return false;
return find(m_index, m_index + ARRAY_SIZE(m_index), ind);
}
};
}