summaryrefslogtreecommitdiffstats
path: root/src/corelib/mimetypes/qmimetypeparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QMimeTypeParser: replace a QString::arg() chain with QString::asprintf()Marc Mutz2016-03-151-2/+6
| | | | | | | Saves ~250b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: Ic92c4ac1bb20230cfbb929bdf5c7f385d7b604e5 Reviewed-by: David Faure <david.faure@kdab.com>
* QMimeTypeParser: plaster error paths with Q_UNLIKELYMarc Mutz2016-03-131-2/+2
| | | | | | | | | | | | ... when more than a return would be executed, to prompt the compiler to move it out of the way of the normal execution path. Unexpectedly costs ~200b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I0ebfb56af7c2262f64271a1b0ec46533e6000bc9 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
* QMimeTypeParser: scope a variable betterMarc Mutz2016-02-241-3/+3
| | | | | | | | | | | | | 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>
* QMimeTypeParser: don't use the heap to create QMimeMagicRulesMarc Mutz2016-02-241-8/+18
| | | | | | | | | | | | | | | | | | | | | | | | | The function createMagicMatchRule() returned a heap-allocated QMimeMagicRule, and the caller code did not check the return value for nullptr, but copied the rule into a container before deleting the original again. Fix by returning by-value instead. Every C++ compiler will use RVO for this. On top, add an optimistic std::move() when inserting the rule into the container (currently QList, so no rvalue-push_back, yet). While touching the return value, also remove an unholy out-parameter with just local effects by returning a Result struct instead. The rest of the code remains full of out- parameters, of course. Add one Q_UNLIKELY and two qUtf16Printable() as drive-bys. Saves ~300b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I4374ab41f38502cd5c64ac37d106ca4bc6e00327 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QMimeTypeParser: use QStringBuilder moreMarc Mutz2016-02-241-3/+2
| | | | | | | | | | | Replace QString::arg() with QStringBuilder, use QStringLiteral where appropriate, and remove it where it isn't (e.g. in QStringBuilder expressions). Saves ~750b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I2471c849db79f477677213f9a155053248800590 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QMimeTypeParser: use QStringRef moreMarc Mutz2016-02-241-10/+10
| | | | | | | | | | | | | | | | | Keep the return values of QXmlStream*::value() around as QStringRefs for as long as possible. Avoids conversions to QString, among other things, for: - comparison to another string - conversion to int - conversion to UTF-8 or Latin-1 byte arrays Add a pair of Q_UNLIKELY as a drive-by. Saves ~900b in text size on optimized GCC 5.3 Linux AMD64 builds. Change-Id: I17d440a11aeb8675979483f89e66d0a088ccc605 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QMimeDatabase: warn instead of asserting on bad magic.David Faure2015-09-041-31/+9
| | | | | | | | | | | | | | | An invalid mime magic definition could lead to an assert. Replaced with a qWarning. Move all checking to the QMimeMagicRule constructor, and do keep invalid rules since they are need to parse child rules. Unit test added, with QTest::ignoreMessage when using the XML backend (there's no warning from update-mime-database when using the cache). Also make it easier to add more shared mime info files for tests. Task-number: QTBUG-44319 Done-with: Eike Ziller <eike.ziller@theqtcompany.com> Change-Id: Ie39a160a106b650cdcee88778fa7eff9e932a988 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Introduce QT_NO_MIMETYPESérgio Martins2015-02-171-0/+4
| | | | | | | | | | | | | The mime type stuff generates one of the biggest translation units in QtCore due to the compressed 1.7MB freedesktop.org.xml resource. With QT_NO_MIMETYPE, libQt5Core.so is almost 400Kb smaller (4.8MB->4.4MB gcc 4.9 stripped release build) Change-Id: I5339090994034355724ff4deddb64720e81baeaf Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: David Faure <david.faure@kdab.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* add macro wrap for QXmlStream related codeJing Bai2012-08-311-0/+8
| | | | | | | | To fix a compile error when QXmlStream is removed by defining macro, but it is still used in some files. Change-Id: I776c799732212b7401767440448248fc7b5dc480 Reviewed-by: David Faure <faure@kde.org>
* Doc: Add \inmodule QtCore to all QtCore class doc bodiesThiago Macieira2012-08-231-0/+2
| | | | | Change-Id: I19100755c97cc155c76a859e19940e9f9222d34e Reviewed-by: Casper van Donderen <casper.vandonderen@nokia.com>
* Remove extra lines in mimetypesABBAPOH2012-04-011-2/+0
| | | | | Change-Id: Ic7ec295b2a0b23a21f44f880f29df13503f8ef3a Reviewed-by: David Faure <faure@kde.org>
* Remove QMimeTypeParserBase from docABBAPOH2012-04-011-0/+1
| | | | | Change-Id: I64d6b4f3209316e28bddb98f221a2c5a45e3e3d0 Reviewed-by: David Faure <faure@kde.org>
* qmimetypeparser: more optimized definition of string constantsDavid Faure2012-02-241-21/+21
| | | | | Change-Id: I0cbc0fef63814ab037bea66ab35b3aa8b6ec800c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Import QMimeType / QMimeDatabase into QtCore.David Faure2012-02-181-0/+342
History of the development before the import: ssh://codereview.qt-project.org/playground/mimetypes.git Mimetype definitions come from shared-mime-info where available (UNIX systems), loaded using a mmap'ed binary cache generated by update-mime-database. As a fallback if no cache is found, we parse the raw XML files otherwise. This makes the MIME type support fast and with very low memory usage on UNIX, and it makes it easy to use on Windows (no dependency on shared-mime-info, Qt even includes a freedesktop.xml file to use if none are found on the system). Change-Id: I27b05008216ff936dc463bd80d3893422bfb940e Reviewed-by: Richard J. Moore <rich@kde.org>