Skip to content

Commit 1cfb149

Browse files
committed
ci: fix clang tidy after PR 2769
1 parent f5918b4 commit 1cfb149

13 files changed

+29
-30
lines changed

silkworm/db/datastore/common/ranges/caching_view.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ struct CachingViewFactory {
118118
}
119119
};
120120

121-
inline constexpr CachingViewFactory caching;
121+
inline constexpr CachingViewFactory caching; // NOLINT(*-identifier-naming)
122122

123123
} // namespace silkworm::views

silkworm/db/datastore/common/ranges/if_view.hpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,13 @@ class IfView : public std::ranges::view_interface<IfView<Range1, Range2>> {
111111
std::nullopt,
112112
std::nullopt,
113113
};
114-
} else {
115-
return Iterator{
116-
std::nullopt,
117-
std::nullopt,
118-
std::ranges::begin(range2_),
119-
std::ranges::end(range2_),
120-
};
121114
}
115+
return Iterator{
116+
std::nullopt,
117+
std::nullopt,
118+
std::ranges::begin(range2_),
119+
std::ranges::end(range2_),
120+
};
122121
}
123122

124123
std::default_sentinel_t end() const { return std::default_sentinel; }

silkworm/db/datastore/common/ranges/lazy_view.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class LazyView : public std::ranges::view_interface<LazyView<TRangeFactory, TRan
3434
LazyView& operator=(LazyView&& other) noexcept {
3535
range_factory_ = std::exchange(std::move(other.range_factory_), std::nullopt);
3636
range_ = std::exchange(std::move(other.range_), std::nullopt);
37-
return this;
37+
return *this;
3838
};
3939

4040
std::ranges::iterator_t<TRange> begin() { return std::ranges::begin(range()); }

silkworm/db/datastore/common/ranges/merge_unique_view.hpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,8 @@ class MergeUniqueView : public std::ranges::view_interface<MergeUniqueView<Range
6262
sentinel2_{std::ranges::end(range2)},
6363
comp_{comp},
6464
proj1_{std::move(proj1)},
65-
proj2_{std::move(proj2)} {
66-
selector_ = select(it1_ended(), it2_ended());
67-
}
65+
proj2_{std::move(proj2)},
66+
selector_{select(it1_ended(), it2_ended())} {}
6867

6968
reference operator*() const {
7069
switch (selector_) {
@@ -138,13 +137,13 @@ class MergeUniqueView : public std::ranges::view_interface<MergeUniqueView<Range
138137
return 1;
139138
}
140139

141-
Range1Iterator it1_;
142-
Range1Sentinel sentinel1_;
143-
Range2Iterator it2_;
144-
Range2Sentinel sentinel2_;
140+
Range1Iterator it1_{};
141+
Range1Sentinel sentinel1_{};
142+
Range2Iterator it2_{};
143+
Range2Sentinel sentinel2_{};
145144
const Comp* comp_{nullptr};
146-
Proj1 proj1_;
147-
Proj2 proj2_;
145+
Proj1 proj1_{};
146+
Proj2 proj2_{};
148147
char selector_{0};
149148
};
150149

silkworm/db/datastore/common/ranges/unique_view.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ struct UniqueViewFactory {
4242
};
4343

4444
template <class Comp = MergeCompareFunc, class Proj = std::identity>
45-
inline constexpr UniqueViewFactory<Comp, Proj> unique;
45+
inline constexpr UniqueViewFactory<Comp, Proj> unique; // NOLINT(*-identifier-naming)
4646

4747
} // namespace silkworm::views

silkworm/db/datastore/kvdb/domain_range_latest_query.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ struct DomainRangeLatestQuery {
6161
return decode_kv_pair(kv_pair);
6262
};
6363

64-
auto exec_with_eager_begin(Bytes key_start, Bytes key_end, bool ascending) {
64+
auto exec_with_eager_begin(const Bytes& key_start, Bytes key_end, bool ascending) {
6565
SILKWORM_ASSERT(ascending); // descending is not implemented
6666

6767
using CursorKVIteratorRaw = CursorKVIterator<DomainKeyDecoder<RawDecoder<ByteView>>, DomainValueDecoder<RawDecoder<ByteView>>>;
@@ -101,12 +101,12 @@ struct DomainRangeLatestQuery {
101101
TKeyEncoder key_start_encoder;
102102
key_start_encoder.value = key_start;
103103
Slice key_start_slice = key_start_encoder.encode();
104-
Bytes key_start_data = Bytes{from_slice(key_start_slice)};
104+
Bytes key_start_data = Bytes{from_slice(key_start_slice)}; // TODO(canepat) extract data from encoder instead of copying
105105

106106
TKeyEncoder key_end_encoder;
107107
key_end_encoder.value = key_end;
108108
Slice key_end_slice = key_end_encoder.encode();
109-
Bytes key_end_data = Bytes{from_slice(key_end_slice)};
109+
Bytes key_end_data = Bytes{from_slice(key_end_slice)}; // TODO(canepat) extract data from encoder instead of copying
110110

111111
auto exec_func = [query = *this, key_start = std::move(key_start_data), key_end = std::move(key_end_data), ascending]() mutable {
112112
return query.exec_with_eager_begin(std::move(key_start), std::move(key_end), ascending);

silkworm/db/datastore/kvdb/history_range_by_keys_query.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ struct HistoryRangeByKeysQuery {
126126
} else {
127127
begin_it = CursorMoveIterator{std::move(begin_cursor), MoveOperation::multi_nextkey_firstvalue};
128128

129-
seek_func = [timestamp](std::shared_ptr<ROCursor> base_cursor) -> std::shared_ptr<ROCursor> {
129+
seek_func = [timestamp](const std::shared_ptr<ROCursor>& base_cursor) -> std::shared_ptr<ROCursor> {
130130
auto cursor = base_cursor->clone();
131131
auto result = cursor->current();
132132
SILKWORM_ASSERT(result);

silkworm/db/datastore/kvdb/history_range_in_period_query.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ struct HistoryRangeInPeriodQuery {
113113
if (key_decoder.value.timestamp.value < ts_range.start) {
114114
*skip_current_key = false;
115115
return {};
116-
} else if (key_decoder.value.timestamp.value < ts_range.end) {
116+
}
117+
if (key_decoder.value.timestamp.value < ts_range.end) {
117118
*skip_current_key = true;
118119
return cursor;
119120
}

silkworm/db/datastore/kvdb/query_test.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ enum class EntityKind {
4747
class QueryTest {
4848
public:
4949
QueryTest(EntityName name, Schema::DatabaseDef schema)
50-
: name_{name},
50+
: name_{std::move(name)},
5151
db_{
5252
open_env(EnvConfig{.path = tmp_dir_.path().string(), .create = true, .in_memory = true}),
5353
std::move(schema),

silkworm/db/datastore/snapshots/domain_range_latest_query.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct DomainRangeLatestSegmentQuery {
4646

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

49-
auto exec_with_eager_begin(Bytes key_start, Bytes key_end, bool ascending) {
49+
auto exec_with_eager_begin(const Bytes& key_start, Bytes key_end, bool ascending) {
5050
SILKWORM_ASSERT(ascending); // descending is not implemented
5151

5252
auto begin_it = entity_.btree_index.seek(key_start, entity_.kv_segment).value_or(btree::BTreeIndex::Cursor{});

silkworm/db/datastore/snapshots/elias_fano/elias_fano_list.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class EliasFanoList32 {
112112
private:
113113
EliasFanoList32() = default;
114114

115-
uint64_t upper(uint64_t c) const;
115+
uint64_t upper(uint64_t i) const;
116116
uint64_t derive_fields();
117117

118118
static constexpr size_t kCountLength{sizeof(uint64_t)};

silkworm/db/datastore/snapshots/history_range_by_keys_query.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct HistoryRangeByKeysSegmentQuery {
7070
return std::pair{std::move(key_data), std::move(*value_opt)};
7171
}
7272

73-
auto exec_with_eager_begin(Bytes key_start, Bytes key_end, datastore::Timestamp timestamp, bool ascending) {
73+
auto exec_with_eager_begin(const Bytes& key_start, Bytes key_end, datastore::Timestamp timestamp, bool ascending) {
7474
SILKWORM_ASSERT(ascending); // descending is not implemented
7575

7676
InvertedIndexLowerBoundKeyOffsetSegmentQuery lower_bound_query{entity_.inverted_index};
@@ -79,7 +79,7 @@ struct HistoryRangeByKeysSegmentQuery {
7979
auto ii_reader = entity_.inverted_index.kv_segment_reader<RawDecoder<Bytes>>();
8080
auto begin_it = offset ? ii_reader.seek(*offset) : ii_reader.end();
8181

82-
auto lookup_kv_pair_func = [query = *this, timestamp, ascending](std::pair<Bytes&, elias_fano::EliasFanoList32&>&& ii_entry) {
82+
auto lookup_kv_pair_func = [query = *this, timestamp, ascending](std::pair<Bytes&, elias_fano::EliasFanoList32&> ii_entry) {
8383
return query.lookup_kv_pair(timestamp, ascending, std::move(ii_entry.first), ii_entry.second);
8484
};
8585

silkworm/db/datastore/snapshots/history_range_in_period_query.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct HistoryRangeInPeriodSegmentQuery {
7171
auto exec(datastore::TimestampRange ts_range, bool ascending) {
7272
SILKWORM_ASSERT(ascending); // descending is not implemented
7373

74-
auto lookup_kv_pair_func = [query = *this, ts_range, ascending](std::pair<Bytes&, elias_fano::EliasFanoList32&>&& ii_entry) {
74+
auto lookup_kv_pair_func = [query = *this, ts_range, ascending](std::pair<Bytes&, elias_fano::EliasFanoList32&> ii_entry) {
7575
return query.lookup_kv_pair(ts_range, ascending, std::move(ii_entry.first), ii_entry.second);
7676
};
7777

0 commit comments

Comments
 (0)