summaryrefslogtreecommitdiffstats
path: root/src/corelib/json
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2016-02-02 12:57:21 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-02-12 16:33:04 +0000
commit448e9fdb57f6a7f7c2ad3986231039f21b20f854 (patch)
treeb262a925f800d923057b6c53da5037f450fed735 /src/corelib/json
parent8dc55367ca3993f465f270ef79c2cb212d821d0c (diff)
Enable NRVO in QJsonObject::keys()
... for poor compilers (such as GCC). The test (!d) was changed to match what other member functions test for, e.g. toVariantHash(). Change-Id: I85aee0df6e50da3623ad0afce24abb586e0bd1bc Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/corelib/json')
-rw-r--r--src/corelib/json/qjsonobject.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp
index 27f937e750..e43d811157 100644
--- a/src/corelib/json/qjsonobject.cpp
+++ b/src/corelib/json/qjsonobject.cpp
@@ -270,16 +270,14 @@ QVariantHash QJsonObject::toVariantHash() const
*/
QStringList QJsonObject::keys() const
{
- if (!d)
- return QStringList();
-
QStringList keys;
- keys.reserve(o->length);
- for (uint i = 0; i < o->length; ++i) {
- QJsonPrivate::Entry *e = o->entryAt(i);
- keys.append(e->key());
+ if (o) {
+ keys.reserve(o->length);
+ for (uint i = 0; i < o->length; ++i) {
+ QJsonPrivate::Entry *e = o->entryAt(i);
+ keys.append(e->key());
+ }
}
-
return keys;
}