QMimeDatabase: replace a QStack<QString> with std::stack<QString, QStringList>

A QStringList is almost as efficient as a QVector<QString>.
More importantly, the QStringList case can share code with
the myriad of other QStringList users, in particular
because std::stack is but the thinnest of wrappers around
its underlying container.

Saves 1400b in text size on optimized GCC 4.9 Linux AMD64
builds.

Change-Id: If37ed55802aa8a529ca772df465990ded0aaba7f
Reviewed-by: David Faure <david.faure@kdab.com>
bb10
Marc Mutz 2015-12-29 14:10:50 +01:00
parent cc2ea22a30
commit 5feebcc973
1 changed files with 6 additions and 6 deletions

View File

@ -47,11 +47,11 @@
#include <QtCore/QSet>
#include <QtCore/QBuffer>
#include <QtCore/QUrl>
#include <QtCore/QStack>
#include <QtCore/QDebug>
#include <algorithm>
#include <functional>
#include <stack>
QT_BEGIN_NAMESPACE
@ -218,13 +218,13 @@ bool QMimeDatabasePrivate::inherits(const QString &mime, const QString &parent)
{
const QString resolvedParent = provider()->resolveAlias(parent);
//Q_ASSERT(provider()->resolveAlias(mime) == mime);
QStack<QString> toCheck;
std::stack<QString, QStringList> toCheck;
toCheck.push(mime);
while (!toCheck.isEmpty()) {
const QString current = toCheck.pop();
if (current == resolvedParent)
while (!toCheck.empty()) {
if (toCheck.top() == resolvedParent)
return true;
const auto parents = provider()->parents(current);
const auto parents = provider()->parents(toCheck.top());
toCheck.pop();
for (const QString &par : parents)
toCheck.push(par);
}