Commit 4ef97051 authored by Sergio Martins's avatar Sergio Martins
Browse files

Use QList::reserve(), reduces reallocations.

parent d6ca0b13
......@@ -134,6 +134,7 @@ QByteArray SentActionAttribute::type() const
QByteArray SentActionAttribute::serialized() const
{
QVariantList list;
list.reserve(d->mActions.count());
foreach (const Action &action, d->mActions) {
QVariantMap map;
map.insert(QString::number(action.type()), action.value());
......
......@@ -354,6 +354,7 @@ bool TransportManager::isEmpty() const
QList<int> TransportManager::transportIds() const
{
QList<int> rv;
rv.reserve(d->transports.count());
foreach (Transport *t, d->transports) {
rv << t->id();
}
......@@ -363,6 +364,7 @@ QList<int> TransportManager::transportIds() const
QStringList TransportManager::transportNames() const
{
QStringList rv;
rv.reserve(d->transports.count());
foreach (Transport *t, d->transports) {
rv << t->name();
}
......@@ -566,6 +568,7 @@ void TransportManagerPrivate::slotTransportsChanged()
int TransportManagerPrivate::createId() const
{
QList<int> usedIds;
usedIds.reserve(1 + transports.count());
foreach (Transport *t, transports) {
usedIds << t->id();
}
......
Markdown is supported
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