Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The reserve function can judge before allocating #693

Open
maths644311798 opened this issue Jun 6, 2024 · 0 comments
Open

The reserve function can judge before allocating #693

maths644311798 opened this issue Jun 6, 2024 · 0 comments

Comments

@maths644311798
Copy link

In /native/src/seal/dynarray.h,

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant