summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-01-23 02:04:48 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-01-23 11:44:06 +0000
commit2fed43d8438b3fb751230aa2a8115de92789ccf3 (patch)
treeeed73480587bc4a3e791a558ba9f28ba7c0ccce7 /src/widgets
parent81d6906ad9fa8ad3f73b151a1e8564ffaeccc3cf (diff)
Q*Application: don't allocate memory just to compare C strings
Instead of creating a QByteArray, possibly normalizing a leading '--' (one allocation, plus possibly one copy), simply use the old 'ol str(n)cmp, skipping the first character if the argument starts with '--'. It also fixes parsing of -stylesheet and other options which were erroneously parsed using indexOf() != -1, when they should have used startsWith(). Also saves 504/742/522b in text size for QtCore/QtGui/QtWidgets, resp., on optimized GCC 5.3 Linux AMD64 builds. Change-Id: Ida868badac3fb9b77285417ee537c861ccc4fc06 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/kernel/qapplication.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp
index e20e820f12..91302d9e62 100644
--- a/src/widgets/kernel/qapplication.cpp
+++ b/src/widgets/kernel/qapplication.cpp
@@ -478,22 +478,24 @@ void QApplicationPrivate::process_cmdline()
j = 1;
for (i=1; i<argc; i++) { // if you add anything here, modify QCoreApplication::arguments()
- if (argv[i] && *argv[i] != '-') {
+ if (!argv[i])
+ continue;
+ if (*argv[i] != '-') {
argv[j++] = argv[i];
continue;
}
- QByteArray arg = argv[i];
- if (arg.startsWith("--"))
- arg.remove(0, 1);
- if (arg == "-qdevel" || arg == "-qdebug") {
+ const char *arg = argv[i];
+ if (arg[1] == '-') // startsWith("--")
+ ++arg;
+ if (strcmp(arg, "-qdevel") == 0 || strcmp(arg, "-qdebug") == 0) {
// obsolete argument
#ifndef QT_NO_STYLE_STYLESHEET
- } else if (arg == "-stylesheet" && i < argc -1) {
+ } else if (strcmp(arg, "-stylesheet") == 0 && i < argc -1) {
styleSheet = QLatin1String("file:///");
styleSheet.append(QString::fromLocal8Bit(argv[++i]));
- } else if (arg.indexOf("-stylesheet=") != -1) {
+ } else if (strncmp(arg, "-stylesheet=", 12) == 0) {
styleSheet = QLatin1String("file:///");
- styleSheet.append(QString::fromLocal8Bit(arg.right(arg.length() - 12)));
+ styleSheet.append(QString::fromLocal8Bit(arg + 12));
#endif
} else if (qstrcmp(arg, "-widgetcount") == 0) {
widgetCount = true;