Commit de3e5212 authored by Friedrich W. H. Kossebau's avatar Friedrich W. H. Kossebau
Browse files

TransportManagerPrivate::createId: no need to keep 0 in the set to check

By using bounded(1, RAND_MAX) 0 should not be generated anway

GIT_SILENT
parent ac4988b0
Pipeline #73975 passed with stage
in 3 minutes and 47 seconds
......@@ -520,13 +520,13 @@ void TransportManagerPrivate::slotTransportsChanged()
int TransportManagerPrivate::createId() const
{
QVector<int> usedIds;
usedIds.reserve(1 + transports.count());
usedIds.reserve(transports.size());
for (Transport *t : std::as_const(transports)) {
usedIds << t->id();
}
usedIds << 0; // 0 is default for unknown
int newId;
do {
// 0 is default for unknown, so use 1 as lower value accepted
newId = QRandomGenerator::global()->bounded(1, RAND_MAX);
} while (usedIds.contains(newId));
return newId;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment