inline void reserve(std::size_t capacity)
{
std::size_t copy_size = std::min<>(capacity, size_);
// Create new allocation and copy over value
auto new_data(util::allocate<T>(capacity, pool_));
std::copy_n(cbegin(), copy_size, new_data.get());
std::swap(data_, new_data);
// Set the coeff_count and capacity
capacity_ = capacity;
size_ = copy_size;
}
I think we can judge if capacity > capacity_ before allocating memory.
The current behavior causes the function Ciphertext::operator=(const Ciphertext &assign) slower than the construction function of Ciphertext.
In /native/src/seal/dynarray.h,
I think we can judge if
capacity > capacity_
before allocating memory. The current behavior causes the functionCiphertext::operator=(const Ciphertext &assign)
slower than the construction function of Ciphertext.