From aca299715fc93b77c695cbce750f5f59ee164d9a Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 30 Nov 2015 14:18:01 +0100 Subject: [PATCH] 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 --- src/widgets/itemviews/qdirmodel.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/widgets/itemviews/qdirmodel.cpp b/src/widgets/itemviews/qdirmodel.cpp index f18233b64c..8a7ab3c63c 100644 --- a/src/widgets/itemviews/qdirmodel.cpp +++ b/src/widgets/itemviews/qdirmodel.cpp @@ -34,7 +34,6 @@ #include "qdirmodel.h" #ifndef QT_NO_DIRMODEL -#include #include #include #include @@ -49,6 +48,9 @@ #include #include +#include +#include + /*! \enum QDirModel::Roles \value FileIconRole @@ -163,10 +165,11 @@ void QDirModelPrivate::clear(QDirNode *parent) const void QDirModelPrivate::invalidate() { - QStack nodes; + std::stack > nodes; nodes.push(&root); while (!nodes.empty()) { - const QDirNode *current = nodes.pop(); + const QDirNode *current = nodes.top(); + nodes.pop(); current->stat = false; const QVector &children = current->children; for (const auto &child : children)