Skip to content
Snippets Groups Projects
Commit cba443f7 authored by Jan Trávníček's avatar Jan Trávníček
Browse files

save allocations using casts to const

parent 22c8b1b6
No related branches found
No related tags found
No related merge requests found
......@@ -44,8 +44,8 @@ Alternation::~Alternation() noexcept {
elements.clear();
}
 
const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > Alternation::getElements() const {
return std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > >(elements.begin(), elements.end());
const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > & Alternation::getElements() const {
return * reinterpret_cast<const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > * > (&elements);
}
 
void Alternation::insertElement(const RegExpElement& element) {
......
......@@ -39,7 +39,7 @@ public:
/**
* @return elements
*/
const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > getElements() const;
const std::set<std::shared_ptr<const RegExpElement>, std::owner_less<std::shared_ptr<const RegExpElement> > > & getElements() const;
 
/**
* @param element to insert
......
......@@ -43,8 +43,8 @@ Concatenation::~Concatenation() noexcept {
elements.clear();
}
 
const std::vector<std::shared_ptr<const RegExpElement> > Concatenation::getElements() const {
return std::vector<std::shared_ptr<const RegExpElement> >(elements.begin(), elements.end());
const std::vector<std::shared_ptr<const RegExpElement> > & Concatenation::getElements() const {
return * reinterpret_cast<const std::vector<std::shared_ptr<const RegExpElement> > * > (&elements);
}
 
void Concatenation::appendElement(const RegExpElement& element) {
......
......@@ -39,7 +39,7 @@ public:
/**
* @return elements
*/
const std::vector<std::shared_ptr<const RegExpElement> > getElements() const;
const std::vector<std::shared_ptr<const RegExpElement> > & getElements() const;
 
/**
* @param element to append
......
......@@ -42,8 +42,8 @@ regexp::Iteration::~Iteration() noexcept {
 
}
 
const std::shared_ptr<const RegExpElement> Iteration::getElement() const {
return std::shared_ptr<const RegExpElement>(element);
const std::shared_ptr<const RegExpElement> & Iteration::getElement() const {
return * reinterpret_cast<const std::shared_ptr<const RegExpElement> * > (&element);
}
 
void Iteration::setElement(const RegExpElement& element) {
......
......@@ -39,7 +39,7 @@ public:
/**
* @return element
*/
const std::shared_ptr<const RegExpElement> getElement() const;
const std::shared_ptr<const RegExpElement> & getElement() const;
/**
* @param element to iterate
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment