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
9 changes: 6 additions & 3 deletions libcxx/include/__vector/vector_bool.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <__algorithm/copy.h>
#include <__algorithm/copy_backward.h>
#include <__algorithm/copy_n.h>
#include <__algorithm/fill_n.h>
#include <__algorithm/iterator_operations.h>
#include <__algorithm/max.h>
Expand Down Expand Up @@ -701,7 +702,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v
__alloc_(__storage_traits::select_on_container_copy_construction(__v.__alloc_)) {
if (__v.size() > 0) {
__vallocate(__v.size());
__construct_at_end(__v.begin(), __v.end(), __v.size());
std::copy_n(__v.__begin_, __external_cap_to_internal(__v.size()), __begin_);
__size_ = __v.size();
}
}

Expand All @@ -710,7 +712,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>::vector(const vector& __v
: __begin_(nullptr), __size_(0), __cap_(0), __alloc_(__a) {
if (__v.size() > 0) {
__vallocate(__v.size());
__construct_at_end(__v.begin(), __v.end(), __v.size());
std::copy_n(__v.__begin_, __external_cap_to_internal(__v.size()), __begin_);
__size_ = __v.size();
}
}

Expand All @@ -723,7 +726,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX20 vector<bool, _Allocator>& vector<bool, _Allocator>
__vdeallocate();
__vallocate(__v.__size_);
}
std::copy(__v.__begin_, __v.__begin_ + __external_cap_to_internal(__v.__size_), __begin_);
std::copy_n(__v.__begin_, __external_cap_to_internal(__v.size()), __begin_);
}
__size_ = __v.__size_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@
#include <benchmark/benchmark.h>
#include <vector>

static void BM_vector_bool_copy_ctor(benchmark::State& state) {
std::vector<bool> vec(100, true);

for (auto _ : state) {
benchmark::DoNotOptimize(vec);
std::vector<bool> vec2(vec);
benchmark::DoNotOptimize(vec2);
}
}
BENCHMARK(BM_vector_bool_copy_ctor);

static void BM_vector_bool_size_ctor(benchmark::State& state) {
for (auto _ : state) {
std::vector<bool> vec(100, true);
Expand Down
Loading