From 9e350bea33feb24078747f33ebafe091f2cc5a03 Mon Sep 17 00:00:00 2001 From: g-arslan Date: Thu, 21 May 2020 17:10:47 +0300 Subject: [PATCH] replace shift array with std::rotate --- src/Columns/ColumnVector.cpp | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Columns/ColumnVector.cpp b/src/Columns/ColumnVector.cpp index 20fc68c0a14..58c4645d0c5 100644 --- a/src/Columns/ColumnVector.cpp +++ b/src/Columns/ColumnVector.cpp @@ -124,25 +124,6 @@ namespace }; } -template -void shiftArrayRight(T & arr, size_t bound) -{ - bound %= arr.size(); - size_t gcd = std::gcd(arr.size(), bound); - for (size_t i = 0; i < gcd; ++i) - { - size_t j = i; - do - { - size_t next = j + bound; - if (next >= arr.size()) - next -= arr.size(); - std::swap(arr[j], arr[next]); - j = next; - } while (j != i); - } -} - template void ColumnVector::getSpecialPermutation(bool reverse, size_t limit, int nan_direction_hint, IColumn::Permutation & res, IColumn::SpecialSort special_sort) const @@ -219,7 +200,7 @@ void ColumnVector::getPermutation(bool reverse, size_t limit, int nan_directi if (nans_to_move) { - shiftArrayRight(res, reverse ? s - nans_to_move : nans_to_move); + std::rotate(std::begin(res), std::begin(res) + (reverse ? nans_to_move : s - nans_to_move), std::end(res)); } } return;