summaryrefslogtreecommitdiffstats
path: root/document
diff options
context:
space:
mode:
authorHåvard Pettersen <havardpe@yahooinc.com>2022-06-23 14:56:17 +0000
committerHåvard Pettersen <havardpe@yahooinc.com>2022-06-23 14:56:17 +0000
commitcf07447ee08081fa316035d67323a86b70cefbf2 (patch)
treeb34884691d0be10368eea1db129eb7ff707eeeaa /document
parent550e4802c3376a5cf339027a22d05c32cb3a38db (diff)
pass pointers where nullptr is an option
Diffstat (limited to 'document')
-rw-r--r--document/src/vespa/document/fieldvalue/structfieldvalue.cpp14
-rw-r--r--document/src/vespa/document/repo/fixedtyperepo.h4
2 files changed, 11 insertions, 7 deletions
diff --git a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
index 529e608533e..7975dd3a327 100644
--- a/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/structfieldvalue.cpp
@@ -50,8 +50,8 @@ StructFieldValue::getStructType() const {
void
StructFieldValue::lazyDeserialize(const FixedTypeRepo &repo, uint16_t version, SerializableArray::EntryMap && fm, ByteBuffer buffer)
{
- _repo = &repo.getDocumentTypeRepo();
- _doc_type = &repo.getDocumentType();
+ _repo = repo.getDocumentTypeRepoPtr();
+ _doc_type = repo.getDocumentTypePtr();
_version = version;
_fields.set(std::move(fm), std::move(buffer));
@@ -117,7 +117,7 @@ StructFieldValue::getField(vespalib::stringref name) const
namespace {
void
-createFV(FieldValue & value, const DocumentTypeRepo & repo, nbostream & stream, const DocumentType & doc_type, uint32_t version)
+createFV(FieldValue & value, const DocumentTypeRepo * repo, nbostream & stream, const DocumentType * doc_type, uint32_t version)
{
FixedTypeRepo frepo(repo, doc_type);
try {
@@ -142,9 +142,9 @@ StructFieldValue::getFieldValue(const Field& field) const
FieldValue::UP value(field.getDataType().createFieldValue());
if ((_repo == nullptr) && (_doc_type != nullptr)) {
DocumentTypeRepo tmpRepo(*_doc_type);
- createFV(*value, tmpRepo, stream, *_doc_type, _version);
+ createFV(*value, &tmpRepo, stream, _doc_type, _version);
} else {
- createFV(*value, *_repo, stream, *_doc_type, _version);
+ createFV(*value, _repo, stream, _doc_type, _version);
}
return value;
}
@@ -172,9 +172,9 @@ StructFieldValue::getFieldValue(const Field& field, FieldValue& value) const
nbostream_longlivedbuf stream(buf.c_str(), buf.size());
if ((_repo == nullptr) && (_doc_type != nullptr)) {
DocumentTypeRepo tmpRepo(*_doc_type);
- createFV(value, tmpRepo, stream, *_doc_type, _version);
+ createFV(value, &tmpRepo, stream, _doc_type, _version);
} else {
- createFV(value, *_repo, stream, *_doc_type, _version);
+ createFV(value, _repo, stream, _doc_type, _version);
}
return true;
}
diff --git a/document/src/vespa/document/repo/fixedtyperepo.h b/document/src/vespa/document/repo/fixedtyperepo.h
index ca37d893718..f1f9230bfd3 100644
--- a/document/src/vespa/document/repo/fixedtyperepo.h
+++ b/document/src/vespa/document/repo/fixedtyperepo.h
@@ -17,6 +17,8 @@ public:
: _repo(&repo), _doc_type(repo.getDefaultDocType()) {}
FixedTypeRepo(const DocumentTypeRepo &repo, const DocumentType &doc_type) noexcept
: _repo(&repo), _doc_type(&doc_type) {}
+ FixedTypeRepo(const DocumentTypeRepo *repo, const DocumentType *doc_type) noexcept
+ : _repo(repo), _doc_type(doc_type) {}
FixedTypeRepo(const DocumentTypeRepo &repo, const vespalib::string &type) noexcept;
const DataType *getDataType(int32_t id) const { return _repo->getDataType(*_doc_type, id); }
@@ -24,6 +26,8 @@ public:
const AnnotationType *getAnnotationType(int32_t id) const { return _repo->getAnnotationType(*_doc_type, id); }
const DocumentTypeRepo &getDocumentTypeRepo() const { return *_repo; }
const DocumentType &getDocumentType() const noexcept { return *_doc_type; }
+ const DocumentTypeRepo *getDocumentTypeRepoPtr() const { return _repo; }
+ const DocumentType *getDocumentTypePtr() const noexcept { return _doc_type; }
};
} // namespace document