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

remove redundant std::move #8478

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

rockeet
Copy link
Contributor

@rockeet rockeet commented Jul 1, 2021

No description provided.

Copy link
Contributor

@zhichao-cao zhichao-cao left a comment

Choose a reason for hiding this comment

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

It is not redundant, we need it to avoid the status check

@rockeet
Copy link
Contributor Author

rockeet commented Jul 1, 2021

It is not redundant, we need it to avoid the status check

It should be expressed explicitly, I've fixed it

@zhichao-cao zhichao-cao requested a review from ajkr July 1, 2021 18:15
@zhichao-cao
Copy link
Contributor

@ajkr you may take a look?

@ajkr
Copy link
Contributor

ajkr commented Jul 1, 2021

Doesn't matter to me. It appears to do the same work in a slightly more roundabout and slightly less suspicious-looking way.

@ajkr ajkr removed their request for review July 1, 2021 18:37
#ifdef ROCKSDB_ASSERT_STATUS_CHECKED
mutable bool checked_ = false;
#endif // ROCKSDB_ASSERT_STATUS_CHECKED
const char* state_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we move the line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

move the line here eliminate paddings and reduces sizeof(Status) by 8 bytes when ROCKSDB_ASSERT_STATUS_CHECKED is defined.

@facebook-github-bot
Copy link
Contributor

@zhichao-cao has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@@ -266,4 +266,8 @@ inline IOStatus status_to_io_status(Status&& status) {
}
}

inline Status io_status_to_status(IOStatus& io_s) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@anand1976 Are you ok this this change?

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems ok to me. Can we make it io_statuc_to_status(IOStatus&& io_s)? I think doing std::move on a lvalue reference is a bit of an anti-pattern.

Copy link
Contributor

Choose a reason for hiding this comment

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

This seems unnecessary (and violating Google C++ style on names). What's wrong with

Status(io_s)

or

static_cast<const Status&>(io_s);

? If you're going to motivate use of move semantics, I wouldn't use a case where it's eligible for copy elision. https://en.cppreference.com/w/cpp/language/copy_elision

@@ -266,4 +266,8 @@ inline IOStatus status_to_io_status(Status&& status) {
}
}

inline Status io_status_to_status(IOStatus& io_s) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems ok to me. Can we make it io_statuc_to_status(IOStatus&& io_s)? I think doing std::move on a lvalue reference is a bit of an anti-pattern.

@@ -1348,7 +1348,7 @@ Status DBImpl::LockWAL() {
// future writes
WriteStatusCheck(status);
}
return std::move(status);
return io_status_to_status(status);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make the type of status explicit in line 1343?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@facebook-github-bot
Copy link
Contributor

@rockeet has updated the pull request. You must reimport the pull request before landing.

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

Successfully merging this pull request may close these issues.

None yet

6 participants