Skip to content
Snippets Groups Projects
Commit 82241e64 authored by Henry Weller's avatar Henry Weller
Browse files

UList::swap: implemented fast version which swaps the size and storage pointer

parent 4cd1e853
Branches
Tags
No related merge requests found
...@@ -81,22 +81,8 @@ void Foam::UList<T>::operator=(const T& t) ...@@ -81,22 +81,8 @@ void Foam::UList<T>::operator=(const T& t)
template<class T> template<class T>
void Foam::UList<T>::swap(UList<T>& a) void Foam::UList<T>::swap(UList<T>& a)
{ {
if (a.size_ != this->size_) Swap(size_, a.size_);
{ Swap(v_, a.v_);
FatalErrorIn("UList<T>::swap(const UList<T>&)")
<< "ULists have different sizes: "
<< this->size_ << " " << a.size_
<< abort(FatalError);
}
List_ACCESS(T, (*this), vp);
List_ACCESS(T, a, ap);
T tmp;
List_FOR_ALL((*this), i)
tmp = List_CELEM((*this), vp, i);
List_ELEM((*this), vp, i) = List_CELEM(a, ap, i);
List_ELEM(a, ap, i) = tmp;
List_END_FOR_ALL
} }
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment