diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-08-29 11:38:34 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-08-29 11:38:34 +0200 |
commit | bfeb39f0ad4a6b2c2b1d09757507c42ef78a1c60 (patch) | |
tree | a25a8936794a6c98c00eeabb7b669d97cfeec080 /document | |
parent | ee29a7aeb10021c55064f6c5268daefe23897f0d (diff) |
Reduce use of new in summary field converter unit test.
Diffstat (limited to 'document')
-rw-r--r-- | document/src/vespa/document/annotation/spantree.cpp | 16 | ||||
-rw-r--r-- | document/src/vespa/document/annotation/spantree.h | 8 |
2 files changed, 19 insertions, 5 deletions
diff --git a/document/src/vespa/document/annotation/spantree.cpp b/document/src/vespa/document/annotation/spantree.cpp index d483d6c08ca..65cccc97b26 100644 --- a/document/src/vespa/document/annotation/spantree.cpp +++ b/document/src/vespa/document/annotation/spantree.cpp @@ -12,20 +12,32 @@ namespace document { SpanTree::~SpanTree() = default; size_t +SpanTree::annotate(Annotation&& annotation_) { + _annotations.push_back(std::move(annotation_)); + return _annotations.size() - 1; +} + +size_t SpanTree::annotate(std::unique_ptr<Annotation> annotation_) { _annotations.push_back(std::move(*annotation_)); return _annotations.size() - 1; } size_t +SpanTree::annotate(const SpanNode &node, Annotation&& annotation_) { + annotation_.setSpanNode(node); + return annotate(std::move(annotation_)); +} + +size_t SpanTree::annotate(const SpanNode &node, std::unique_ptr<Annotation> annotation_) { annotation_->setSpanNode(node); return annotate(std::move(annotation_)); } size_t -SpanTree::annotate(const SpanNode &node, const AnnotationType &type) { - return annotate(node, std::make_unique<Annotation>(type)); +SpanTree::annotate(const SpanNode &node, const AnnotationType &annotation_type) { + return annotate(node, Annotation(annotation_type)); } void diff --git a/document/src/vespa/document/annotation/spantree.h b/document/src/vespa/document/annotation/spantree.h index 7635350025b..c427c9ec7bd 100644 --- a/document/src/vespa/document/annotation/spantree.h +++ b/document/src/vespa/document/annotation/spantree.h @@ -29,9 +29,11 @@ public: ~SpanTree(); // The annotate functions return the annotation index. - size_t annotate(std::unique_ptr<Annotation> annotation); - size_t annotate(const SpanNode &node, std::unique_ptr<Annotation> a); - size_t annotate(const SpanNode &node, const AnnotationType &a_type); + size_t annotate(Annotation&& annotation_); + size_t annotate(std::unique_ptr<Annotation> annotation_); + size_t annotate(const SpanNode& node, Annotation&& annotation_); + size_t annotate(const SpanNode& node, std::unique_ptr<Annotation> annotation_); + size_t annotate(const SpanNode& node, const AnnotationType& annotation_type); Annotation & annotation(size_t index) { return _annotations[index]; } const Annotation & annotation(size_t index) const { return _annotations[index]; } |