diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-08-29 12:22:48 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-08-29 12:22:48 +0200 |
commit | 91a1b02e5b7e387005577af36ae37c8553f38cd4 (patch) | |
tree | 5de192e0c1c890fde23d4bc177b8314b8f4908e1 /document | |
parent | bfeb39f0ad4a6b2c2b1d09757507c42ef78a1c60 (diff) |
Reduce number of overloads for document::SpanTree::annotate.
Diffstat (limited to 'document')
4 files changed, 3 insertions, 17 deletions
diff --git a/document/src/tests/annotation/annotation_test.cpp b/document/src/tests/annotation/annotation_test.cpp index 2700cfcf96f..b18fa113d9b 100644 --- a/document/src/tests/annotation/annotation_test.cpp +++ b/document/src/tests/annotation/annotation_test.cpp @@ -156,8 +156,8 @@ TEST("requireThatAnnotationsCanHaveValues") { TEST("requireThatAnnotationsCanReferenceAnnotations") { auto root = std::make_unique<SpanList>(); SpanTree tree("html", std::move(root)); - size_t san_index = tree.annotate(makeUP(new Annotation(text_type))); - size_t fran_index = tree.annotate(makeUP(new Annotation(text_type))); + size_t san_index = tree.annotate(Annotation(text_type)); + size_t fran_index = tree.annotate(Annotation(text_type)); AnnotationReferenceDataType annotation_ref_type(text_type, 101); ArrayDataType array_type(annotation_ref_type); diff --git a/document/src/tests/serialization/vespadocumentserializer_test.cpp b/document/src/tests/serialization/vespadocumentserializer_test.cpp index 40d78327ab4..7528878bfb5 100644 --- a/document/src/tests/serialization/vespadocumentserializer_test.cpp +++ b/document/src/tests/serialization/vespadocumentserializer_test.cpp @@ -626,7 +626,7 @@ TEST("requireThatDocumentWithDocumentCanBeSerialized") { const AnnotationType *a_type =my_repo.getAnnotationType(*inner_type, a_id); StringFieldValue str("foo"); auto tree = std::make_unique<SpanTree>("name", std::make_unique<Span>(0, 3)); - tree->annotate(std::make_unique<Annotation>(*a_type)); + tree->annotate(Annotation(*a_type)); setSpanTree(str, *tree); diff --git a/document/src/vespa/document/annotation/spantree.cpp b/document/src/vespa/document/annotation/spantree.cpp index 65cccc97b26..4d24b4ce788 100644 --- a/document/src/vespa/document/annotation/spantree.cpp +++ b/document/src/vespa/document/annotation/spantree.cpp @@ -18,24 +18,12 @@ SpanTree::annotate(Annotation&& annotation_) { } 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 &annotation_type) { return annotate(node, Annotation(annotation_type)); } diff --git a/document/src/vespa/document/annotation/spantree.h b/document/src/vespa/document/annotation/spantree.h index c427c9ec7bd..03ee820466c 100644 --- a/document/src/vespa/document/annotation/spantree.h +++ b/document/src/vespa/document/annotation/spantree.h @@ -30,9 +30,7 @@ public: // The annotate functions return the annotation index. 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]; } |