summaryrefslogtreecommitdiffstats
path: root/src/corelib/json/qjsonvalue.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-05-04 14:51:37 +0200
committerMarc Mutz <marc.mutz@kdab.com>2016-05-09 08:10:13 +0000
commit4a4b377cd0912615477083d0f597907a51d025a9 (patch)
tree46def6af310bd47b60191af504f2befd088b14ed /src/corelib/json/qjsonvalue.h
parent0b1b06ffc0a334263c01e32e5bfb50b4d96ba70d (diff)
QJsonValue: don't create a temporary QString on every toString() invocation
The vast majority of users call toString() without the optional defaultValue. So do it like the toArray() and toObject() methods and split toString() into two overloads, so the common case no longer needs to pass a temporaray QString. Saves ~1.4 and ~1KiB in QtCore and QtGui text size, resp., on optimized GCC 6.0 Linux AMD64 builds, even though we added a new function to QtCore, too. Change-Id: Ibe02397ca49ce11fdb58f5c5fc69e909bf94c1c6 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib/json/qjsonvalue.h')
-rw-r--r--src/corelib/json/qjsonvalue.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/corelib/json/qjsonvalue.h b/src/corelib/json/qjsonvalue.h
index 8b6221ea4c..1ce7f745e0 100644
--- a/src/corelib/json/qjsonvalue.h
+++ b/src/corelib/json/qjsonvalue.h
@@ -107,7 +107,8 @@ public:
bool toBool(bool defaultValue = false) const;
int toInt(int defaultValue = 0) const;
double toDouble(double defaultValue = 0) const;
- QString toString(const QString &defaultValue = QString()) const;
+ QString toString() const;
+ QString toString(const QString &defaultValue) const;
QJsonArray toArray() const;
QJsonArray toArray(const QJsonArray &defaultValue) const;
QJsonObject toObject() const;