diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-05-02 19:11:33 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-05 17:32:36 +0000 |
commit | 468ed544a336858142712c7d073c7849fce3f8b1 (patch) | |
tree | c000a1122747d352530a266a9d865768614a7641 /src/plugins | |
parent | a234bbbf648c777153013ce747ddad84a84894af (diff) |
GLTFIO: brush up ctors of nested structs
- pass QJsonObject by cref instead of by value
- make ctors explicit
- use ctor-init-list as much as possible
Saves ~350B in text size on optimized GCC 6 Linux
AMD64 builds.
Change-Id: I343bf4a36cce6c04de62097db7bbae34e7309863
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/sceneparsers/gltf/gltfio.cpp | 28 | ||||
-rw-r--r-- | src/plugins/sceneparsers/gltf/gltfio.h | 7 |
2 files changed, 16 insertions, 19 deletions
diff --git a/src/plugins/sceneparsers/gltf/gltfio.cpp b/src/plugins/sceneparsers/gltf/gltfio.cpp index 2b8dea4da..ba5b697d5 100644 --- a/src/plugins/sceneparsers/gltf/gltfio.cpp +++ b/src/plugins/sceneparsers/gltf/gltfio.cpp @@ -399,11 +399,11 @@ GLTFIO::BufferData::BufferData() { } -GLTFIO::BufferData::BufferData(QJsonObject json) +GLTFIO::BufferData::BufferData(const QJsonObject &json) + : length(json.value(KEY_BYTE_LENGTH).toInt()), + path(json.value(KEY_URI).toString()), + data(nullptr) { - path = json.value(KEY_URI).toString(); - length = json.value(KEY_BYTE_LENGTH).toInt(); - data = nullptr; } GLTFIO::ParameterData::ParameterData() : @@ -412,10 +412,10 @@ GLTFIO::ParameterData::ParameterData() : } -GLTFIO::ParameterData::ParameterData(QJsonObject json) +GLTFIO::ParameterData::ParameterData(const QJsonObject &json) + : semantic(json.value(KEY_SEMANTIC).toString()), + type(json.value(KEY_TYPE).toInt()) { - type = json.value(KEY_TYPE).toInt(); - semantic = json.value(KEY_SEMANTIC).toString(); } GLTFIO::AccessorData::AccessorData() @@ -429,15 +429,13 @@ GLTFIO::AccessorData::AccessorData() } GLTFIO::AccessorData::AccessorData(const QJsonObject &json) + : bufferViewName(json.value(KEY_BUFFER_VIEW).toString()), + type(accessorTypeFromJSON(json.value(KEY_COMPONENT_TYPE).toInt())), + dataSize(accessorDataSizeFromJson(json.value(KEY_TYPE).toString())), + count(json.value(KEY_COUNT).toInt()), + offset(0), + stride(0) { - bufferViewName = json.value(KEY_BUFFER_VIEW).toString(); - offset = 0; - stride = 0; - int componentType = json.value(KEY_COMPONENT_TYPE).toInt(); - type = accessorTypeFromJSON(componentType); - count = json.value(KEY_COUNT).toInt(); - dataSize = accessorDataSizeFromJson(json.value(KEY_TYPE).toString()); - const auto byteOffset = json.value(KEY_BYTE_OFFSET); if (!byteOffset.isUndefined()) offset = byteOffset.toInt(); diff --git a/src/plugins/sceneparsers/gltf/gltfio.h b/src/plugins/sceneparsers/gltf/gltfio.h index 27010cd0e..900364043 100644 --- a/src/plugins/sceneparsers/gltf/gltfio.h +++ b/src/plugins/sceneparsers/gltf/gltfio.h @@ -104,8 +104,7 @@ private: { public: BufferData(); - - BufferData(QJsonObject json); + explicit BufferData(const QJsonObject &json); quint64 length; QString path; @@ -117,7 +116,7 @@ private: { public: ParameterData(); - ParameterData(QJsonObject json); + explicit ParameterData(const QJsonObject &json); QString semantic; int type; @@ -127,7 +126,7 @@ private: { public: AccessorData(); - AccessorData(const QJsonObject& json); + explicit AccessorData(const QJsonObject& json); QString bufferViewName; QAttribute::VertexBaseType type; |