QDirModel: replace a QStack with a std::stack
std::stack, based on std::vector, tends to be more efficient that QStack, based on QVector, but, crucially, it is an actual stack, so doesn't allow, say, iteration or insertion in the middle, which QStack does allow. Since a lot of places where QStack is used use at least some of those non-stack features, protect this instance which doesn't, yet, from becoming another such site. Since the use of std::stack with the default std::deque increases text size by almost 1K, and a vector makes a perfectly good stack, use std::vector as the backing container (which std::stack, being a container adapter, allows easily). Saves ~0.5KiB in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I51c8fb1dc4e9907ae00ed1cee8f320304321b322 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>bb10
parent
ad16478a76
commit
aca299715f
|
|
@ -34,7 +34,6 @@
|
|||
#include "qdirmodel.h"
|
||||
|
||||
#ifndef QT_NO_DIRMODEL
|
||||
#include <qstack.h>
|
||||
#include <qfile.h>
|
||||
#include <qfilesystemmodel.h>
|
||||
#include <qurl.h>
|
||||
|
|
@ -49,6 +48,9 @@
|
|||
#include <private/qabstractitemmodel_p.h>
|
||||
#include <qdebug.h>
|
||||
|
||||
#include <stack>
|
||||
#include <vector>
|
||||
|
||||
/*!
|
||||
\enum QDirModel::Roles
|
||||
\value FileIconRole
|
||||
|
|
@ -163,10 +165,11 @@ void QDirModelPrivate::clear(QDirNode *parent) const
|
|||
|
||||
void QDirModelPrivate::invalidate()
|
||||
{
|
||||
QStack<const QDirNode*> nodes;
|
||||
std::stack<const QDirNode*, std::vector<const QDirNode*> > nodes;
|
||||
nodes.push(&root);
|
||||
while (!nodes.empty()) {
|
||||
const QDirNode *current = nodes.pop();
|
||||
const QDirNode *current = nodes.top();
|
||||
nodes.pop();
|
||||
current->stat = false;
|
||||
const QVector<QDirNode> &children = current->children;
|
||||
for (const auto &child : children)
|
||||
|
|
|
|||
Loading…
Reference in New Issue