QMimeTypeParser: scope a variable better
The variable being a QVector, this means replacing default construction followed by one move-assignment per loop iteration with a StartElement state with RVO-catching a return value. Saves ~320b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I618d31ad0816f9ad1a89a6b2e39481258f1e0878 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
This commit is contained in:
parent
aca859cbc4
commit
c05f2985eb
@ -206,12 +206,11 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
QList<QMimeMagicRule> rules; // toplevel rules
|
||||
QXmlStreamReader reader(dev);
|
||||
ParseState ps = ParseBeginning;
|
||||
QXmlStreamAttributes atts;
|
||||
while (!reader.atEnd()) {
|
||||
switch (reader.readNext()) {
|
||||
case QXmlStreamReader::StartElement:
|
||||
case QXmlStreamReader::StartElement: {
|
||||
ps = nextState(ps, reader.name());
|
||||
atts = reader.attributes();
|
||||
const QXmlStreamAttributes atts = reader.attributes();
|
||||
switch (ps) {
|
||||
case ParseMimeType: { // start parsing a MIME type name
|
||||
const QString name = atts.value(QLatin1String(mimeTypeAttributeC)).toString();
|
||||
@ -297,6 +296,7 @@ bool QMimeTypeParserBase::parse(QIODevice *dev, const QString &fileName, QString
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
// continue switch QXmlStreamReader::Token...
|
||||
case QXmlStreamReader::EndElement: // Finished element
|
||||
|
Loading…
Reference in New Issue
Block a user