Skip to content

Commit

Permalink
varray: optimize serialization for stateless allocator
Browse files Browse the repository at this point in the history
  • Loading branch information
evaleev committed Jul 14, 2023
1 parent 39b4f26 commit 5a45699
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions btas/varray/varray.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,11 @@ namespace madness {
template <class Archive, typename T, typename A>
struct ArchiveLoadImpl<Archive, btas::varray<T, A>> {
static inline void load(const Archive& ar, btas::varray<T, A>& x) {
A allocator;
ar & allocator;
x = btas::varray<T, A>(allocator);
if constexpr (!std::allocator_traits<A>::is_always_equal::value) {
A allocator;
ar & allocator;
x = btas::varray<T, A>(allocator);
}
typename btas::varray<T, A>::size_type n{};
ar& n;
x.resize(n);
Expand All @@ -484,7 +486,10 @@ namespace madness {
template <class Archive, typename T, typename A>
struct ArchiveStoreImpl<Archive, btas::varray<T, A>> {
static inline void store(const Archive& ar, const btas::varray<T, A>& x) {
ar& x.get_allocator() & x.size();
if constexpr (!std::allocator_traits<A>::is_always_equal::value) {
ar & x.get_allocator();
}
ar & x.size();
for (const typename btas::varray<T, A>::value_type& xi : x) ar& xi;
}
};
Expand Down

0 comments on commit 5a45699

Please sign in to comment.