Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion benchmarks/src/unique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <algorithm>
#include <benchmark/benchmark.h>
#include <cstdint>
#include <numeric>
#include <random>
#include <type_traits>
#include <vector>
Expand All @@ -19,7 +20,9 @@ void u(benchmark::State& state) {
std::binomial_distribution<TD> dis(5);

std::vector<T, not_highly_aligned_allocator<T>> src(2552);
std::generate(src.begin(), src.end(), [&] { return static_cast<T>(dis(gen)); });
std::iota(src.begin(), src.begin() + 390, T{0});
std::iota(src.end() - 390, src.end(), T{0});
std::generate(src.begin() + 390, src.end() - 390, [&] { return static_cast<T>(dis(gen)); });

std::vector<T, not_highly_aligned_allocator<T>> v;
v.reserve(src.size());
Expand Down
10 changes: 8 additions & 2 deletions stl/src/vector_algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5187,8 +5187,6 @@ namespace {
// It is not possible to leave them untouched while keeping this optimization efficient.
// This should not be a problem though, as they should be either overwritten by the next step,
// or left in the removed range.
// 'remove' does not require any specific values,
// 'unique' needs the last element value to be preserved, as it will be loaded again.
for (; _Nx != _Size_h / _Ew; ++_Nx) {
// Inner loop needed for cases where the shuffle mask operates on element parts rather than whole
// elements; for whole elements there would be one iteration.
Expand Down Expand Up @@ -5476,6 +5474,8 @@ void* __stdcall __std_remove_8(void* _First, void* const _Last, const uint64_t _
}

void* __stdcall __std_unique_1(void* _First, void* _Last) noexcept {
_First = const_cast<void*>(__std_adjacent_find_1(_First, _Last));

if (_First == _Last) {
return _First;
}
Expand All @@ -5496,6 +5496,8 @@ void* __stdcall __std_unique_1(void* _First, void* _Last) noexcept {
}

void* __stdcall __std_unique_2(void* _First, void* _Last) noexcept {
_First = const_cast<void*>(__std_adjacent_find_2(_First, _Last));

if (_First == _Last) {
return _First;
}
Expand All @@ -5516,6 +5518,8 @@ void* __stdcall __std_unique_2(void* _First, void* _Last) noexcept {
}

void* __stdcall __std_unique_4(void* _First, void* _Last) noexcept {
_First = const_cast<void*>(__std_adjacent_find_4(_First, _Last));

if (_First == _Last) {
return _First;
}
Expand Down Expand Up @@ -5543,6 +5547,8 @@ void* __stdcall __std_unique_4(void* _First, void* _Last) noexcept {
}

void* __stdcall __std_unique_8(void* _First, void* _Last) noexcept {
_First = const_cast<void*>(__std_adjacent_find_8(_First, _Last));

if (_First == _Last) {
return _First;
}
Expand Down