diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-04-07 11:27:08 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2022-04-07 11:27:08 +0000 |
commit | 4186095e8161e79cb592bdeb3c956f7c1b2be767 (patch) | |
tree | d5001b166cf9e91bf50424b86e50a6dacd8bd437 /document/src | |
parent | fb342f05a465dfb96a366ebae88df904b632cad5 (diff) |
Move some more variable maps
Diffstat (limited to 'document/src')
5 files changed, 28 insertions, 11 deletions
diff --git a/document/src/vespa/document/fieldvalue/iteratorhandler.h b/document/src/vespa/document/fieldvalue/iteratorhandler.h index 2f7b5d522e9..bbf24b77fb2 100644 --- a/document/src/vespa/document/fieldvalue/iteratorhandler.h +++ b/document/src/vespa/document/fieldvalue/iteratorhandler.h @@ -77,6 +77,7 @@ public: void setArrayIndex(uint32_t index) { _arrayIndexStack.back() = index; } ModificationStatus modify(FieldValue &fv) { return doModify(fv); } fieldvalue::VariableMap &getVariables() { return _variables; } + fieldvalue::VariableMap && stealVariables() { return std::move(_variables); } void setVariables(fieldvalue::VariableMap vars) { _variables = std::move(vars); } virtual bool createMissingPath() const { return false; } private: diff --git a/document/src/vespa/document/select/resultlist.cpp b/document/src/vespa/document/select/resultlist.cpp index 5bb2f510e0d..e6ce79fe117 100644 --- a/document/src/vespa/document/select/resultlist.cpp +++ b/document/src/vespa/document/select/resultlist.cpp @@ -153,11 +153,11 @@ ResultList::operator||(const ResultList& other) const } ResultList -ResultList::operator!() const { +ResultList::operator!() && { ResultList result; - for (const auto & it : _results) { - result.add(it.first, !*it.second); + for (auto & it : _results) { + result.add(std::move(it.first), !*it.second); } return result; diff --git a/document/src/vespa/document/select/resultlist.h b/document/src/vespa/document/select/resultlist.h index 3f810004168..c13a2c79f5a 100644 --- a/document/src/vespa/document/select/resultlist.h +++ b/document/src/vespa/document/select/resultlist.h @@ -14,7 +14,7 @@ public: typedef std::vector<ResultPair> Results; typedef Results::iterator iterator; typedef Results::const_iterator const_iterator; - using const_reverse_iterator = Results::const_reverse_iterator; + using reverse_iterator = Results::const_reverse_iterator; ResultList(); ResultList(ResultList &&) noexcept; @@ -32,7 +32,7 @@ public: ResultList operator&&(const ResultList& other) const; ResultList operator||(const ResultList& other) const; - ResultList operator!() const; + ResultList operator!() &&; void print(std::ostream& out, bool verbose, const std::string& indent) const override; @@ -45,8 +45,8 @@ public: const Results& getResults() const { return _results; } const_iterator begin() const { return _results.begin(); } const_iterator end() const { return _results.end(); } - const_reverse_iterator rbegin() const { return _results.rbegin(); } - const_reverse_iterator rend() const { return _results.rend(); } + reverse_iterator rbegin() { return _results.rbegin(); } + reverse_iterator rend() { return _results.rend(); } private: Results _results; diff --git a/document/src/vespa/document/select/value.cpp b/document/src/vespa/document/select/value.cpp index aabd09b2558..a36a25103da 100644 --- a/document/src/vespa/document/select/value.cpp +++ b/document/src/vespa/document/select/value.cpp @@ -380,13 +380,29 @@ StructValue::operator==(const Value& value) const } void -StructValue::print(std::ostream& out, bool verbose, - const std::string& indent) const +StructValue::print(std::ostream& out, bool verbose, const std::string& indent) const { (void) verbose; (void) indent; out << "<no struct representation in language yet>"; } +namespace { + +fieldvalue::VariableMap +cloneMap(const fieldvalue::VariableMap &map) { + fieldvalue::VariableMap m; + for (const auto & item : map) { + if (item.second.key) { + m.emplace(item.first, fieldvalue::IndexValue(*item.second.key)); + } else { + m.emplace(item.first, fieldvalue::IndexValue(item.second.index)); + } + } + return m; +} + +} + template <typename Predicate> ResultList ArrayValue::doCompare(const Value& value, const Predicate& cmp) const @@ -415,7 +431,7 @@ ArrayValue::doCompare(const Value& value, const Predicate& cmp) const if (item.first.empty()) { resultForNoVariables.set(result.toEnum()); } else { - results.add(item.first, result); + results.add(cloneMap(item.first), result); } } for (uint32_t i(0); i < resultForNoVariables.size(); i++) { diff --git a/document/src/vespa/document/select/valuenodes.cpp b/document/src/vespa/document/select/valuenodes.cpp index c770974adfe..1c7d47d0591 100644 --- a/document/src/vespa/document/select/valuenodes.cpp +++ b/document/src/vespa/document/select/valuenodes.cpp @@ -263,7 +263,7 @@ IteratorHandler::onPrimitive(uint32_t fid, const Content& fv) { if (!_firstValue && getVariables().empty()) { _firstValue = getInternalValue(fv.getValue()); } else { - _values.emplace_back(std::move(getVariables()), Value::SP(getInternalValue(fv.getValue()).release())); + _values.emplace_back(stealVariables(), Value::SP(getInternalValue(fv.getValue()).release())); } } |