summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-09-11 09:28:39 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-09-11 09:28:39 +0000
commit0074fd7b101a9415fa6f6c5311f307cd311508f1 (patch)
tree07f9e617e69ef03ef3b9e3b0eeef77aaab1dceb6
parent6ba482ddc41bfaa9b34ae66b641bcdf452c86792 (diff)
Use a move constructor to avoid expensive copy when not necessary.
-rw-r--r--document/src/vespa/document/fieldvalue/predicatefieldvalue.cpp17
-rw-r--r--document/src/vespa/document/fieldvalue/predicatefieldvalue.h6
2 files changed, 15 insertions, 8 deletions
diff --git a/document/src/vespa/document/fieldvalue/predicatefieldvalue.cpp b/document/src/vespa/document/fieldvalue/predicatefieldvalue.cpp
index 68331a50262..6766f794141 100644
--- a/document/src/vespa/document/fieldvalue/predicatefieldvalue.cpp
+++ b/document/src/vespa/document/fieldvalue/predicatefieldvalue.cpp
@@ -34,9 +34,10 @@ PredicateFieldValue::PredicateFieldValue(const PredicateFieldValue &rhs)
inject(rhs._slime->get(), SlimeInserter(*_slime));
}
-PredicateFieldValue::~PredicateFieldValue() { }
+PredicateFieldValue::~PredicateFieldValue() = default;
-FieldValue &PredicateFieldValue::assign(const FieldValue &rhs) {
+FieldValue &
+PredicateFieldValue::assign(const FieldValue &rhs) {
if (rhs.inherits(PredicateFieldValue::classId)) {
operator=(static_cast<const PredicateFieldValue &>(rhs));
return *this;
@@ -47,7 +48,8 @@ FieldValue &PredicateFieldValue::assign(const FieldValue &rhs) {
}
}
-PredicateFieldValue &PredicateFieldValue::operator=(const PredicateFieldValue &rhs)
+PredicateFieldValue &
+PredicateFieldValue::operator=(const PredicateFieldValue &rhs)
{
_slime = std::make_unique<Slime>();
inject(rhs._slime->get(), SlimeInserter(*_slime));
@@ -55,18 +57,21 @@ PredicateFieldValue &PredicateFieldValue::operator=(const PredicateFieldValue &r
return *this;
}
-int PredicateFieldValue::compare(const FieldValue&rhs) const {
+int
+PredicateFieldValue::compare(const FieldValue&rhs) const {
int diff = FieldValue::compare(rhs);
if (diff != 0) return diff;
const PredicateFieldValue &o = static_cast<const PredicateFieldValue &>(rhs);
return Predicate::compare(*_slime, *o._slime);
}
-void PredicateFieldValue::printXml(XmlOutputStream& out) const {
+void
+PredicateFieldValue::printXml(XmlOutputStream& out) const {
out << XmlContent(PredicatePrinter::print(*_slime));
}
-void PredicateFieldValue::print(std::ostream& out, bool, const std::string&) const {
+void
+PredicateFieldValue::print(std::ostream& out, bool, const std::string&) const {
out << PredicatePrinter::print(*_slime) << "\n";
}
diff --git a/document/src/vespa/document/fieldvalue/predicatefieldvalue.h b/document/src/vespa/document/fieldvalue/predicatefieldvalue.h
index e0df3a38353..7154affc9b0 100644
--- a/document/src/vespa/document/fieldvalue/predicatefieldvalue.h
+++ b/document/src/vespa/document/fieldvalue/predicatefieldvalue.h
@@ -13,13 +13,15 @@ class PredicateFieldValue : public FieldValue {
std::unique_ptr<vespalib::Slime> _slime;
bool _altered;
+ PredicateFieldValue & operator=(const PredicateFieldValue &rhs);
public:
PredicateFieldValue();
PredicateFieldValue(std::unique_ptr<vespalib::Slime> s);
PredicateFieldValue(const PredicateFieldValue &rhs);
- ~PredicateFieldValue();
+ PredicateFieldValue(PredicateFieldValue && rhs) noexcept = default;
+ ~PredicateFieldValue() override;
- PredicateFieldValue &operator=(const PredicateFieldValue &rhs);
+ PredicateFieldValue & operator=(PredicateFieldValue && rhs) noexcept = default;
void accept(FieldValueVisitor &visitor) override { visitor.visit(*this); }
void accept(ConstFieldValueVisitor &visitor) const override { visitor.visit(*this); }