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

use const & for avoiding copy #704

Merged
merged 2 commits into from
Jul 3, 2022
Merged

Conversation

jackwener
Copy link
Member

@jackwener jackwener commented Jul 2, 2022

replace const auto& with const auto & just to unify format.

Add const & to avoid copy

@jackwener jackwener marked this pull request as ready for review July 2, 2022 15:49
@git-hulk
Copy link
Member

git-hulk commented Jul 3, 2022

Thanks @jackwener, merging...

@git-hulk git-hulk merged commit a942549 into apache:unstable Jul 3, 2022
@@ -27,7 +27,7 @@
TEST(LockManager, LockKey) {
LockManager locks(8);
std::vector<rocksdb::Slice> keys = {"abc", "123", "456", "abc", "123"};
for (const auto key : keys) {
Copy link
Member

Choose a reason for hiding this comment

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

I think copying slice maybe more lightweight then using reference?

Copy link
Member

@PragmaTwice PragmaTwice Jul 3, 2022

Choose a reason for hiding this comment

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

Yeah, maybe passing by value is more effective in some cases. Don't know why there are many const Slice& even in rocksdb itself.

@jackwener jackwener deleted the add_ref branch July 3, 2022 07:19
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

Successfully merging this pull request may close these issues.

4 participants