summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@oath.com>2018-06-13 11:19:48 +0200
committerHenning Baldersheim <balder@oath.com>2018-06-13 11:19:48 +0200
commita946f5f31b1186b3f39fad0a71458b7858f46568 (patch)
treef8aa6ae606c95ac9779b96609dd196123f01beea
parentff9cbc3a7f2ec91fbff87d933602676e4a1d3897 (diff)
Only call classFromId once
-rw-r--r--document/src/vespa/document/update/valueupdate.cpp10
-rw-r--r--staging_vespalib/src/vespa/vespalib/objects/identifiable.cpp2
2 files changed, 5 insertions, 7 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);
}
}
diff --git a/staging_vespalib/src/vespa/vespalib/objects/identifiable.cpp b/staging_vespalib/src/vespa/vespalib/objects/identifiable.cpp
index 52c9def3036..7e14fbc0014 100644
--- a/staging_vespalib/src/vespa/vespalib/objects/identifiable.cpp
+++ b/staging_vespalib/src/vespa/vespalib/objects/identifiable.cpp
@@ -48,7 +48,7 @@ Register::Register() :
_listByName()
{ }
-Register::~Register() { }
+Register::~Register() = default;
bool Register::erase(Identifiable::RuntimeClass * c)
{