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

ci: fix clang tidy after PR 2769 #2799

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft

Conversation

canepat
Copy link
Member

@canepat canepat commented Mar 18, 2025

No description provided.

@canepat canepat force-pushed the ci/fix_clang_tidy_after_2769 branch from 1cfb149 to e436224 Compare March 18, 2025 21:01
@@ -61,7 +61,7 @@ struct DomainRangeLatestQuery {
return decode_kv_pair(kv_pair);
};

auto exec_with_eager_begin(Bytes key_start, Bytes key_end, bool ascending) {
auto exec_with_eager_begin(const Bytes& key_start, Bytes key_end, bool ascending) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend to add NOLINT here or pack keys into std::pair in order to preserve symmetry.

@@ -101,12 +101,12 @@ struct DomainRangeLatestQuery {
TKeyEncoder key_start_encoder;
key_start_encoder.value = key_start;
Slice key_start_slice = key_start_encoder.encode();
Bytes key_start_data = Bytes{from_slice(key_start_slice)};
Bytes key_start_data = Bytes{from_slice(key_start_slice)}; // TODO(canepat) extract data from encoder instead of copying
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't bother about this copy, because there's a constant overhead per request (2 copies per request), and keys are not huge. I suggest to not add TODO comments about optimization unless we identify a bottleneck here.

Note that encoders not always contain Bytes inside, so another approach would be required for eliminating this copy.

@@ -72,7 +72,7 @@ struct HistoryRangeByKeysQuery {
};
}

auto exec_with_eager_begin(Bytes key_start, Bytes key_end, Timestamp timestamp, bool ascending) {
auto exec_with_eager_begin(const Bytes& key_start, Bytes key_end, Timestamp timestamp, bool ascending) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend to add NOLINT here or pack keys into std::pair in order to preserve symmetry.

Comment on lines +116 to +117
}
if (key_decoder.value.timestamp.value < ts_range.end) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not a fan of this lint rule. It is not clear what does it improve for us. I feel that the code is less readable and less robust.

@@ -46,7 +46,7 @@ struct DomainRangeLatestSegmentQuery {

using ResultItem = btree::BTreeIndex::Cursor::value_type;

auto exec_with_eager_begin(Bytes key_start, Bytes key_end, bool ascending) {
auto exec_with_eager_begin(const Bytes& key_start, Bytes key_end, bool ascending) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend to add NOLINT here or pack keys into std::pair in order to preserve symmetry.

@@ -57,7 +57,7 @@ struct DomainRangeLatestSegmentQuery {

auto exec(Bytes key_start, Bytes key_end, bool ascending) {
auto exec_func = [query = *this, key_start = std::move(key_start), key_end = std::move(key_end), ascending]() mutable {
return query.exec_with_eager_begin(std::move(key_start), std::move(key_end), ascending);
return query.exec_with_eager_begin(key_start, std::move(key_end), ascending);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you decide to go with const Bytes& key_start I'd still move it for symmetry as you do in other 2 places unless it produces a warning (in which case need to fix 2 other places).

@@ -70,7 +70,7 @@ struct HistoryRangeByKeysSegmentQuery {
return std::pair{std::move(key_data), std::move(*value_opt)};
}

auto exec_with_eager_begin(Bytes key_start, Bytes key_end, datastore::Timestamp timestamp, bool ascending) {
auto exec_with_eager_begin(const Bytes& key_start, Bytes key_end, datastore::Timestamp timestamp, bool ascending) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I recommend to add NOLINT here or pack keys into std::pair in order to preserve symmetry.

@@ -94,7 +94,7 @@ struct HistoryRangeByKeysSegmentQuery {

auto exec(Bytes key_start, Bytes key_end, datastore::Timestamp timestamp, bool ascending) {
auto exec_func = [query = *this, key_start = std::move(key_start), key_end = std::move(key_end), timestamp, ascending]() mutable {
return query.exec_with_eager_begin(std::move(key_start), std::move(key_end), timestamp, ascending);
return query.exec_with_eager_begin(key_start, std::move(key_end), timestamp, ascending);
Copy link
Contributor

Choose a reason for hiding this comment

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

If you decide to go with const Bytes& key_start I'd still move it for symmetry as you do in other 2 places unless it produces a warning (in which case need to fix 2 other places).

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.

2 participants