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

Why not just move m_data in do_move_assign function? #54

Open
Yikai-Liao opened this issue Aug 6, 2024 · 0 comments
Open

Why not just move m_data in do_move_assign function? #54

Yikai-Liao opened this issue Aug 6, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@Yikai-Liao
Copy link

    void do_move_assign(svector&& other) {
        // if (!other.is_direct()) {
        //     // take other's memory, even when empty
        //     set_indirect(other.indirect());
        // } else {
        //     auto* other_ptr = other.data<direction::direct>();
        //     auto s = other.size<direction::direct>();
        //     auto* other_end = other_ptr + s;
        //
        //     std::uninitialized_move(other_ptr, other_end, data<direction::direct>());
        //     std::destroy(other_ptr, other_end);
        //     set_size(s);
        // }
        m_data = std::move(other.m_data);
        other.set_direct_and_size(0);
    }

I notice that the original do move assign function is not efficient (using Vtune), and just move the m_data could significantly improve the performance.

Since the precondition is all uninitialized, I think move m_data directly is just equal to the previous code in results.

@Yikai-Liao Yikai-Liao added the enhancement New feature or request label Aug 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants