Use the STL find function instead of an iterator.

This commit is contained in:
Jonathan Naylor
2016-04-06 17:24:14 +01:00
parent 8d97e8f6f9
commit f7e2cff004
2 changed files with 7 additions and 20 deletions

View File

@@ -18,6 +18,7 @@
#include <cstdio>
#include <cassert>
#include <algorithm>
CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex) :
m_id(id),
@@ -71,22 +72,12 @@ bool CDMRControl::processWakeup(const unsigned char* data)
return false;
}
bool found = false;
if (m_prefixes.size() == 0U)
found = true;
for (std::vector<unsigned int>::const_iterator it = m_prefixes.begin(); it != m_prefixes.end(); ++it) {
if (prefix == *it) {
found = true;
break;
if (m_prefixes.size() > 0U) {
if (std::find(m_prefixes.begin(), m_prefixes.end(), prefix) == m_prefixes.end()) {
LogMessage("Invalid CSBK BS_Dwn_Act received from %u", srcId);
return false;
}
}
if (!found) {
LogMessage("Invalid CSBK BS_Dwn_Act received from %u", srcId);
return false;
}
}
if (bsId == 0xFFFFFFU) {