mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-21 23:45:49 +08:00
Use the STL find function instead of an iterator.
This commit is contained in:
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cassert>
|
#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) :
|
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),
|
m_id(id),
|
||||||
@@ -71,22 +72,12 @@ bool CDMRControl::processWakeup(const unsigned char* data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found = false;
|
if (m_prefixes.size() > 0U) {
|
||||||
|
if (std::find(m_prefixes.begin(), m_prefixes.end(), prefix) == m_prefixes.end()) {
|
||||||
if (m_prefixes.size() == 0U)
|
LogMessage("Invalid CSBK BS_Dwn_Act received from %u", srcId);
|
||||||
found = true;
|
return false;
|
||||||
|
|
||||||
for (std::vector<unsigned int>::const_iterator it = m_prefixes.begin(); it != m_prefixes.end(); ++it) {
|
|
||||||
if (prefix == *it) {
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!found) {
|
|
||||||
LogMessage("Invalid CSBK BS_Dwn_Act received from %u", srcId);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bsId == 0xFFFFFFU) {
|
if (bsId == 0xFFFFFFU) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
unsigned int CDMRSlot::m_id = 0U;
|
unsigned int CDMRSlot::m_id = 0U;
|
||||||
unsigned int CDMRSlot::m_colorCode = 0U;
|
unsigned int CDMRSlot::m_colorCode = 0U;
|
||||||
@@ -1265,12 +1266,7 @@ bool CDMRSlot::validateId(unsigned int id)
|
|||||||
if (m_prefixes.size() == 0U)
|
if (m_prefixes.size() == 0U)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (std::vector<unsigned int>::const_iterator it = m_prefixes.begin(); it != m_prefixes.end(); ++it) {
|
return std::find(m_prefixes.begin(), m_prefixes.end(), prefix) != m_prefixes.end();
|
||||||
if (prefix == *it)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user