moc: replace a QStack<QByteArray> with std::stack<QByteArray, QByteArrayList>

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

For moc, saves almost 1KiB in text size on optimized GCC 4.9
Linux AMD64 builds.

For qdbuscpp2xml, which re-uses moc code, saves ~1.6KiB.

Change-Id: I861e92b3c79e47e0ce892ccf54c9041182aaf212
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
Marc Mutz 2015-12-29 14:10:50 +01:00
parent 08adcc62a7
commit 5c81863019

View File

@ -34,9 +34,10 @@
#ifndef PARSER_H
#define PARSER_H
#include <qstack.h>
#include "symbols.h"
#include <stack>
QT_BEGIN_NAMESPACE
class Parser
@ -57,7 +58,7 @@ public:
};
QList<IncludePath> includes;
QStack<QByteArray> currentFilenames;
std::stack<QByteArray, QByteArrayList> currentFilenames;
inline bool hasNext() const { return (index < symbols.size()); }
inline Token next() { if (index >= symbols.size()) return NOTOKEN; return symbols.at(index++).token; }