diff options
author | Henning Baldersheim <balder@oath.com> | 2018-06-13 11:19:48 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-06-13 11:19:48 +0200 |
commit | a946f5f31b1186b3f39fad0a71458b7858f46568 (patch) | |
tree | f8aa6ae606c95ac9779b96609dd196123f01beea /document | |
parent | ff9cbc3a7f2ec91fbff87d933602676e4a1d3897 (diff) |
Only call classFromId once
Diffstat (limited to 'document')
-rw-r--r-- | document/src/vespa/document/update/valueupdate.cpp | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/document/src/vespa/document/update/valueupdate.cpp b/document/src/vespa/document/update/valueupdate.cpp index 103d9341f0e..b43f9f7f095 100644 --- a/document/src/vespa/document/update/valueupdate.cpp +++ b/document/src/vespa/document/update/valueupdate.cpp @@ -13,20 +13,18 @@ IMPLEMENT_IDENTIFIABLE_ABSTRACT(ValueUpdate, Identifiable); std::unique_ptr<ValueUpdate> ValueUpdate::createInstance(const DocumentTypeRepo& repo, const DataType& type, ByteBuffer& buffer, int serializationVersion) { - ValueUpdate* update(NULL); int32_t classId = 0; buffer.getIntNetwork(classId); const Identifiable::RuntimeClass * rtc(Identifiable::classFromId(classId)); - if (rtc != NULL) { - update = static_cast<ValueUpdate*>(Identifiable::classFromId(classId)->create()); - /// \todo TODO (was warning): Updates are not versioned in serialization format. Will not work with altering it. + if (rtc != nullptr) { + std::unique_ptr<ValueUpdate> update(static_cast<ValueUpdate*>(rtc->create())); + /// \todo TODO (was warning): Updates are not versioned in serialization format. Will not work without altering it. update->deserialize(repo, type, buffer, serializationVersion); + return update; } else { throw std::runtime_error(vespalib::make_string("Could not find a class for classId %d(%x)", classId, classId)); } - - return std::unique_ptr<ValueUpdate>(update); } } |