Commit 88a4ebf4 authored by BRAMAS Berenger's avatar BRAMAS Berenger
Browse files

Use move in the swap function of the quicksorts

parent 9b7d7536
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <cstdlib> #include <cstdlib>
#include <cstring> #include <cstring>
#include <vector> // For parallel without task #include <vector> // For parallel without task
#include <utility> // For move
#include "FGlobal.hpp" #include "FGlobal.hpp"
#include "FMemUtils.hpp" #include "FMemUtils.hpp"
...@@ -43,9 +44,9 @@ protected: ...@@ -43,9 +44,9 @@ protected:
/** swap to value */ /** swap to value */
template <class NumType> template <class NumType>
static inline void Swap(NumType& value, NumType& other){ static inline void Swap(NumType& value, NumType& other){
NumType temp = value; const NumType temp = std::move(value);
value = other; value = std::move(other);
other = temp; other = std::move(temp);
} }
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "FLog.hpp" #include "FLog.hpp"
#include <memory> #include <memory>
#include <utility>
template <class SortType, class CompareType, class IndexType> template <class SortType, class CompareType, class IndexType>
class FQuickSortMpi : public FQuickSort< SortType, CompareType, IndexType> { class FQuickSortMpi : public FQuickSort< SortType, CompareType, IndexType> {
...@@ -38,9 +39,9 @@ class FQuickSortMpi : public FQuickSort< SortType, CompareType, IndexType> { ...@@ -38,9 +39,9 @@ class FQuickSortMpi : public FQuickSort< SortType, CompareType, IndexType> {
static void Swap(SortType& value, SortType& other){ static void Swap(SortType& value, SortType& other){
SortType temp = value; const SortType temp = std::move(value);
value = other; value = std::move(other);
other = temp; other = std::move(temp);
} }
/* A local iteration of qs */ /* A local iteration of qs */
......
Supports Markdown
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