Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

refactor(security): refactor the send func of client_negotiation #620

Merged
merged 4 commits into from
Sep 10, 2020

Conversation

levy5307
Copy link
Contributor

@levy5307 levy5307 commented Sep 9, 2020

refactor the send func of client_negotiation

req->msg = start_output;
send(std::move(req));
_status = negotiation_status::type::SASL_INITIATE;
send(_status, start_output);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use std::move here if you do not want a string copy.

void send(..., std::string msg) { // use value-typed string, allowing string to be move constructed.

_status = req->status = negotiation_status::type::SASL_SELECT_MECHANISMS;
req->msg = mechanism;
send(std::move(req));
send(_status, std::move(mechanism));
Copy link
Member

@acelyc111 acelyc111 Sep 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mechanism is a 'const &', is it movable? Is there any compile complains?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see any compile complains. And I write a test program like this:

    std::string test = "123123";
    const std::string &ref_test = test;
    const std::string &&r_test = std::move(ref_test);
    std::cout << r_test << std::endl;

It works well.

@levy5307 levy5307 merged commit bf610ce into XiaoMi:master Sep 10, 2020
@levy5307 levy5307 deleted the refactor-negotiation-send branch September 10, 2020 03:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants