diff --git a/benchmarks/src/unique.cpp b/benchmarks/src/unique.cpp index 8fb20db444c..2ff40a902f2 100644 --- a/benchmarks/src/unique.cpp +++ b/benchmarks/src/unique.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,9 @@ void u(benchmark::State& state) { std::binomial_distribution dis(5); std::vector> src(2552); - std::generate(src.begin(), src.end(), [&] { return static_cast(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(dis(gen)); }); std::vector> v; v.reserve(src.size()); diff --git a/stl/src/vector_algorithms.cpp b/stl/src/vector_algorithms.cpp index a267d94ca36..5f5584257e7 100644 --- a/stl/src/vector_algorithms.cpp +++ b/stl/src/vector_algorithms.cpp @@ -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. @@ -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(__std_adjacent_find_1(_First, _Last)); + if (_First == _Last) { return _First; } @@ -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(__std_adjacent_find_2(_First, _Last)); + if (_First == _Last) { return _First; } @@ -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(__std_adjacent_find_4(_First, _Last)); + if (_First == _Last) { return _First; } @@ -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(__std_adjacent_find_8(_First, _Last)); + if (_First == _Last) { return _First; }