From 692907525d4f8dd2605800c56f1f662b4fae07ea Mon Sep 17 00:00:00 2001 From: Jan Travnicek <Jan.Travnicek@fit.cvut.cz> Date: Sat, 23 May 2015 13:05:20 +0200 Subject: [PATCH] better move semantics for regexps --- alib2data/src/regexp/formal/FormalRegExp.cpp | 6 +++--- alib2data/src/regexp/formal/FormalRegExp.h | 7 +++---- alib2data/src/regexp/unbounded/UnboundedRegExp.cpp | 6 +++--- alib2data/src/regexp/unbounded/UnboundedRegExp.h | 4 ++-- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/alib2data/src/regexp/formal/FormalRegExp.cpp b/alib2data/src/regexp/formal/FormalRegExp.cpp index 2fe809f160..933b3ed5dc 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.cpp +++ b/alib2data/src/regexp/formal/FormalRegExp.cpp @@ -30,13 +30,13 @@ FormalRegExp::FormalRegExp(const UnboundedRegExp& other) { delete element; } -FormalRegExp::FormalRegExp(const std::set<alphabet::Symbol>& alphabet, const FormalRegExpElement& regExp) { - this->alphabet = alphabet; +FormalRegExp::FormalRegExp(std::set<alphabet::Symbol> alphabet, const FormalRegExpElement& regExp) { + this->alphabet = std::move(alphabet); this->regExp = NULL; setRegExp(regExp); } -FormalRegExp::FormalRegExp(std::set<alphabet::Symbol>&& alphabet, FormalRegExpElement&& regExp) { +FormalRegExp::FormalRegExp(std::set<alphabet::Symbol> alphabet, FormalRegExpElement&& regExp) { this->alphabet = std::move(alphabet); this->regExp = NULL; setRegExp(std::move(regExp)); diff --git a/alib2data/src/regexp/formal/FormalRegExp.h b/alib2data/src/regexp/formal/FormalRegExp.h index 922111a88e..3da1018ab6 100644 --- a/alib2data/src/regexp/formal/FormalRegExp.h +++ b/alib2data/src/regexp/formal/FormalRegExp.h @@ -41,8 +41,8 @@ public: explicit FormalRegExp(); explicit FormalRegExp(const UnboundedRegExp& other); - explicit FormalRegExp(const std::set<alphabet::Symbol>& alphabet, const FormalRegExpElement& regExp); - explicit FormalRegExp(std::set<alphabet::Symbol>&& alphabet, FormalRegExpElement&& regExp); + explicit FormalRegExp(std::set<alphabet::Symbol> alphabet, const FormalRegExpElement& regExp); + explicit FormalRegExp(std::set<alphabet::Symbol> alphabet, FormalRegExpElement&& regExp); explicit FormalRegExp(const FormalRegExpElement& regExp); explicit FormalRegExp(FormalRegExpElement&& regExp); @@ -67,8 +67,7 @@ public: FormalRegExpElement& getRegExp(); /** - * Sets the root node of the regular expression tree. Doesn't perform copy of the regExp param, - * just stores it! + * Sets the root node of the regular expression tree * @param regExp root node to set */ void setRegExp(const FormalRegExpElement& regExp); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp index 085b69274f..58b8a1f31e 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.cpp @@ -30,13 +30,13 @@ UnboundedRegExp::UnboundedRegExp(const FormalRegExp& other) { delete element; } -UnboundedRegExp::UnboundedRegExp(const std::set<alphabet::Symbol>& alphabet, const UnboundedRegExpElement& regExp) { - this->alphabet = alphabet; +UnboundedRegExp::UnboundedRegExp(std::set<alphabet::Symbol> alphabet, const UnboundedRegExpElement& regExp) { + this->alphabet = std::move(alphabet); this->regExp = NULL; setRegExp(regExp); } -UnboundedRegExp::UnboundedRegExp(std::set<alphabet::Symbol>&& alphabet, UnboundedRegExpElement&& regExp) { +UnboundedRegExp::UnboundedRegExp(std::set<alphabet::Symbol> alphabet, UnboundedRegExpElement&& regExp) { this->alphabet = std::move(alphabet); this->regExp = NULL; setRegExp(std::move(regExp)); diff --git a/alib2data/src/regexp/unbounded/UnboundedRegExp.h b/alib2data/src/regexp/unbounded/UnboundedRegExp.h index ceed4113fa..06eed44e26 100644 --- a/alib2data/src/regexp/unbounded/UnboundedRegExp.h +++ b/alib2data/src/regexp/unbounded/UnboundedRegExp.h @@ -41,8 +41,8 @@ public: explicit UnboundedRegExp(); explicit UnboundedRegExp(const FormalRegExp& other); - explicit UnboundedRegExp(const std::set<alphabet::Symbol>& alphabet, const UnboundedRegExpElement& regExp); - explicit UnboundedRegExp(std::set<alphabet::Symbol>&& alphabet, UnboundedRegExpElement&& regExp); + explicit UnboundedRegExp(std::set<alphabet::Symbol> alphabet, const UnboundedRegExpElement& regExp); + explicit UnboundedRegExp(std::set<alphabet::Symbol> alphabet, UnboundedRegExpElement&& regExp); explicit UnboundedRegExp(const UnboundedRegExpElement& regExp); explicit UnboundedRegExp(UnboundedRegExpElement&& regExp); -- GitLab