mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #14715: Drop defunct prevector compat handling
69ca48717ceb31e37e90276278362c809cf98cc6 Implement prevector::fill once (Ben Woosley) 7bad78c2c83d73b7e0518f3e1b835f0157b80ec6 Drop defunct IS_TRIVIALLY_CONSTRUCTIBLE handling from prevector.h (Ben Woosley) Pull request description: This is clean-up post #14651: * Use one implementation of `prevector::fill`, as it's possible now that the implementations are identical. * Only apply the `IS_TRIVIALLY_CONSTRUCTIBLE` handling to the bench file where it is used, and drop the now-unnecessary associated compat includes. Tree-SHA512: 5930b3a17fccd39af10add40202ad97a297aebecc049af72ca920d0d55b3e4c3c30ce864c8a683355895f0196396d4ea56ba9f9637bdc7d16964cdf66c195485
This commit is contained in:
parent
7be48286f4
commit
550b2777fd
@ -10,6 +10,14 @@
|
||||
|
||||
#include <bench/bench.h>
|
||||
|
||||
// GCC 4.8 is missing some C++11 type_traits,
|
||||
// https://www.gnu.org/software/gcc/gcc-5/changes.html
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
|
||||
#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor
|
||||
#else
|
||||
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible
|
||||
#endif
|
||||
|
||||
struct nontrivial_t {
|
||||
int x;
|
||||
nontrivial_t() :x(-1) {}
|
||||
|
10
src/compat.h
10
src/compat.h
@ -10,16 +10,6 @@
|
||||
#include <config/dash-config.h>
|
||||
#endif
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
// GCC 4.8 is missing some C++11 type_traits,
|
||||
// https://www.gnu.org/software/gcc/gcc-5/changes.html
|
||||
#if defined(__GNUC__) && !defined(__clang__) && __GNUC__ < 5
|
||||
#define IS_TRIVIALLY_CONSTRUCTIBLE std::has_trivial_default_constructor
|
||||
#else
|
||||
#define IS_TRIVIALLY_CONSTRUCTIBLE std::is_trivially_default_constructible
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32_WINNT
|
||||
#undef _WIN32_WINNT
|
||||
|
@ -15,8 +15,6 @@
|
||||
#include <iterator>
|
||||
#include <type_traits>
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
/** Implements a drop-in replacement for std::vector<T> which stores up to N
|
||||
* elements directly (without heap allocation). The types Size and Diff are
|
||||
* used to store element counts, and can be any unsigned + signed type.
|
||||
@ -203,11 +201,7 @@ private:
|
||||
T* item_ptr(difference_type pos) { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
|
||||
const T* item_ptr(difference_type pos) const { return is_direct() ? direct_ptr(pos) : indirect_ptr(pos); }
|
||||
|
||||
void fill(T* dst, ptrdiff_t count) {
|
||||
std::fill_n(dst, count, T{});
|
||||
}
|
||||
|
||||
void fill(T* dst, ptrdiff_t count, const T& value) {
|
||||
void fill(T* dst, ptrdiff_t count, const T& value = T{}) {
|
||||
std::fill_n(dst, count, value);
|
||||
}
|
||||
|
||||
@ -226,7 +220,7 @@ private:
|
||||
}
|
||||
|
||||
void fill(T* dst, const T* src, ptrdiff_t count) {
|
||||
if (IS_TRIVIALLY_CONSTRUCTIBLE<T>::value) {
|
||||
if (std::is_trivially_constructible<T>::value) {
|
||||
::memmove(dst, src, count * sizeof(T));
|
||||
} else {
|
||||
for (ptrdiff_t i = 0; i < count; i++) {
|
||||
@ -560,7 +554,7 @@ public:
|
||||
static void assign_to(const_iterator b, const_iterator e, V& v) {
|
||||
// We know that internally the iterators are pointing to continues memory, so we can directly use the pointers here
|
||||
// This avoids internal use of std::copy and operator++ on the iterators and instead allows efficient memcpy/memmove
|
||||
if (IS_TRIVIALLY_CONSTRUCTIBLE<T>::value) {
|
||||
if (std::is_trivially_constructible<T>::value) {
|
||||
auto s = e - b;
|
||||
if (v.size() != s) {
|
||||
v.resize(s);
|
||||
|
Loading…
Reference in New Issue
Block a user