Skip to content

Commit 4501a68

Browse files
committed
cr: remove THolder
1 parent d5d8e97 commit 4501a68

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

ydb/core/tablet_flat/shared_cache_clock_pro.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class TClockProCache : public ICacheCache<TPage> {
3636
struct TPageKeyHash {
3737
using is_transparent = void;
3838

39-
inline size_t operator()(const THolder<TPageEntry>& entry) const {
40-
return TPageTraits::GetHash(entry->Key);
39+
inline size_t operator()(const TPageEntry& entry) const {
40+
return TPageTraits::GetHash(entry.Key);
4141
}
4242

4343
inline size_t operator()(const TPageKey& key) const {
@@ -48,12 +48,12 @@ class TClockProCache : public ICacheCache<TPage> {
4848
struct TPageKeyEqual {
4949
using is_transparent = void;
5050

51-
inline bool operator()(const THolder<TPageEntry>& left, const THolder<TPageEntry>& right) const {
52-
return TPageTraits::Equals(left->Key, right->Key);
51+
inline bool operator()(const TPageEntry& left, const TPageEntry& right) const {
52+
return TPageTraits::Equals(left.Key, right.Key);
5353
}
5454

55-
inline bool operator()(const THolder<TPageEntry>& left, const TPageKey& right) const {
56-
return TPageTraits::Equals(left->Key, right);
55+
inline bool operator()(const TPageEntry& left, const TPageKey& right) const {
56+
return TPageTraits::Equals(left.Key, right);
5757
}
5858
};
5959

@@ -86,7 +86,7 @@ class TClockProCache : public ICacheCache<TPage> {
8686
return {};
8787
} else if (auto it = Entries.find(TPageTraits::GetKey(page)); it != Entries.end()) {
8888
// transforms a 'Cold non-resident' ('Test') page to a 'Hot' page:
89-
TPageEntry* entry = it->Get();
89+
TPageEntry* entry = AsEntry(it);
9090
Y_ABORT_UNLESS(!entry->Page);
9191
return Fill(entry, page);
9292
} else {
@@ -97,7 +97,7 @@ class TClockProCache : public ICacheCache<TPage> {
9797

9898
void Erase(TPage* page) override {
9999
if (auto it = Entries.find(TPageTraits::GetKey(page)); it != Entries.end()) {
100-
TPageEntry* entry = it->Get();
100+
TPageEntry* entry = AsEntry(it);
101101

102102
EraseEntry(entry);
103103

@@ -129,7 +129,7 @@ class TClockProCache : public ICacheCache<TPage> {
129129
TPageEntry* entry = ptr->Node();
130130
auto it = Entries.find(entry->Key);
131131
Y_DEBUG_ABORT_UNLESS(it != Entries.end());
132-
Y_DEBUG_ABORT_UNLESS(it->Get() == entry);
132+
Y_DEBUG_ABORT_UNLESS(AsEntry(it) == entry);
133133

134134
if (count != 0) result << ", ";
135135
if (entry == HandHot) result << "Hot>";
@@ -187,10 +187,9 @@ class TClockProCache : public ICacheCache<TPage> {
187187
TIntrusiveList<TPage> Add(TPage* page) {
188188
Y_DEBUG_ABORT_UNLESS(TPageTraits::GetLocation(page) == EClockProPageLocation::None);
189189

190-
auto entry_ = MakeHolder<TPageEntry>(TPageTraits::GetKey(page), page, TPageTraits::GetSize(page));
191-
auto inserted = Entries.emplace(std::move(entry_));
190+
auto inserted = Entries.emplace(TPageTraits::GetKey(page), page, TPageTraits::GetSize(page));
192191
Y_ABORT_UNLESS(inserted.second);
193-
TPageEntry* entry = inserted.first->Get();
192+
TPageEntry* entry = AsEntry(inserted.first);
194193

195194
LinkEntry(entry);
196195

@@ -319,7 +318,7 @@ class TClockProCache : public ICacheCache<TPage> {
319318

320319
auto it = Entries.find(entry->Key);
321320
Y_ABORT_UNLESS(it != Entries.end());
322-
Y_ABORT_UNLESS(it->Get() == entry);
321+
Y_ABORT_UNLESS(AsEntry(it) == entry);
323322
Entries.erase(it);
324323
}
325324

@@ -396,14 +395,18 @@ class TClockProCache : public ICacheCache<TPage> {
396395
if (ptr) {
397396
ptr = ptr->Next()->Node();
398397
}
399-
}
398+
}
399+
400+
TPageEntry* AsEntry(THashSet<TPageEntry, TPageKeyHash, TPageKeyEqual>::iterator it) const {
401+
return const_cast<TPageEntry*>(&*it);
402+
}
400403

401404
private:
402405
ui64 Limit;
403406
ui64 ColdTarget;
404407

405408
// TODO: unify this with TPageMap
406-
THashSet<THolder<TPageEntry>, TPageKeyHash, TPageKeyEqual> Entries;
409+
THashSet<TPageEntry, TPageKeyHash, TPageKeyEqual> Entries;
407410

408411
TPageEntry* HandHot = nullptr;
409412
TPageEntry* HandCold = nullptr;

0 commit comments

Comments
 (0)