QFileSystemModel: replace inefficient QList<Fetching> with QVector
The type Fetching is larger than a void*, so holding it in QList is needlessly inefficient. Worse, the code could come to depend on the fragile property of (inefficient) QLists that references to elements therein never are invalidated. Fix by holding it in QVector instead. Also optimize the append site by liberal use of std::move(). This code would greatly benefit from emplace_back(), but we can neither assume it's present in std::vector nor do we require the necessary C++11 features that would allow us to implement it in QVector, yet (uniform init and, less so, variadic templates). Change-Id: I50da0ffd557adff57477245d0e8c1fc1fec1ebc1 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>bb10
parent
d569f37dfd
commit
89f9f7cbdf
|
|
@ -472,11 +472,8 @@ QFileSystemModelPrivate::QFileSystemNode *QFileSystemModelPrivate::node(const QS
|
|||
p->bypassFilters[node] = 1;
|
||||
QString dir = q->filePath(this->index(parent));
|
||||
if (!node->hasInformation() && fetch) {
|
||||
Fetching f;
|
||||
f.dir = dir;
|
||||
f.file = element;
|
||||
f.node = node;
|
||||
p->toFetch.append(f);
|
||||
Fetching f = { std::move(dir), std::move(element), node };
|
||||
p->toFetch.append(std::move(f));
|
||||
p->fetchingTimer.start(0, const_cast<QFileSystemModel*>(q));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -324,7 +324,7 @@ public:
|
|||
QString file;
|
||||
const QFileSystemNode *node;
|
||||
};
|
||||
QList<Fetching> toFetch;
|
||||
QVector<Fetching> toFetch;
|
||||
|
||||
};
|
||||
Q_DECLARE_TYPEINFO(QFileSystemModelPrivate::Fetching, Q_MOVABLE_TYPE);
|
||||
|
|
|
|||
Loading…
Reference in New Issue