Skip to content

Commit c99641d

Browse files
authored
move template class member to correct TU for explicit instantiation (#4643)
During recent refactoring a single method of the `template <class BucketT> class SearchableBucketListSnapshotBase` -- the method `SearchableBucketListSnapshotBase<BucketT>::loadKeysInternal` -- got left behind in `SearchableBucketList.cpp` while the rest of the methods got moved to `BucketListSnapshotBase.cpp`. Unfortunately all explicit template instantiations of `SearchableBucketListSnapshotBase` occur in `BucketListSnapshotBase.cpp` and they only cause instantiation of methods _defined in_ the same TU. So the method didn't get instantiated. At least on g++. This was covered up in CI because enabling extrachecks winds up triggering instantiations anyways. But if you turn off extrachecks, master doesn't currently compile on g++. This fixes the bug by moving the method to the right TU.
2 parents 036c3fc + 184c0e9 commit c99641d

File tree

2 files changed

+35
-35
lines changed

2 files changed

+35
-35
lines changed

src/bucket/BucketListSnapshotBase.cpp

+35
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,41 @@ SearchableBucketListSnapshotBase<BucketT>::load(LedgerKey const& k) const
118118
return result;
119119
}
120120

121+
template <class BucketT>
122+
std::optional<std::vector<typename BucketT::LoadT>>
123+
SearchableBucketListSnapshotBase<BucketT>::loadKeysInternal(
124+
std::set<LedgerKey, LedgerEntryIdCmp> const& inKeys,
125+
LedgerKeyMeter* lkMeter, std::optional<uint32_t> ledgerSeq) const
126+
{
127+
ZoneScoped;
128+
129+
// Make a copy of the key set, this loop is destructive
130+
auto keys = inKeys;
131+
std::vector<typename BucketT::LoadT> entries;
132+
auto loadKeysLoop = [&](auto const& b) {
133+
b.loadKeys(keys, entries, lkMeter);
134+
return keys.empty() ? Loop::COMPLETE : Loop::INCOMPLETE;
135+
};
136+
137+
if (!ledgerSeq || *ledgerSeq == mSnapshot->getLedgerSeq())
138+
{
139+
loopAllBuckets(loadKeysLoop, *mSnapshot);
140+
}
141+
else
142+
{
143+
auto iter = mHistoricalSnapshots.find(*ledgerSeq);
144+
if (iter == mHistoricalSnapshots.end())
145+
{
146+
return std::nullopt;
147+
}
148+
149+
releaseAssert(iter->second);
150+
loopAllBuckets(loadKeysLoop, *iter->second);
151+
}
152+
153+
return entries;
154+
}
155+
121156
template <class BucketT>
122157
std::optional<std::vector<typename BucketT::LoadT>>
123158
SearchableBucketListSnapshotBase<BucketT>::loadKeysFromLedger(

src/bucket/SearchableBucketList.cpp

-35
Original file line numberDiff line numberDiff line change
@@ -64,41 +64,6 @@ SearchableLiveBucketListSnapshot::scanForEviction(
6464
return result;
6565
}
6666

67-
template <class BucketT>
68-
std::optional<std::vector<typename BucketT::LoadT>>
69-
SearchableBucketListSnapshotBase<BucketT>::loadKeysInternal(
70-
std::set<LedgerKey, LedgerEntryIdCmp> const& inKeys,
71-
LedgerKeyMeter* lkMeter, std::optional<uint32_t> ledgerSeq) const
72-
{
73-
ZoneScoped;
74-
75-
// Make a copy of the key set, this loop is destructive
76-
auto keys = inKeys;
77-
std::vector<typename BucketT::LoadT> entries;
78-
auto loadKeysLoop = [&](auto const& b) {
79-
b.loadKeys(keys, entries, lkMeter);
80-
return keys.empty() ? Loop::COMPLETE : Loop::INCOMPLETE;
81-
};
82-
83-
if (!ledgerSeq || *ledgerSeq == mSnapshot->getLedgerSeq())
84-
{
85-
loopAllBuckets(loadKeysLoop, *mSnapshot);
86-
}
87-
else
88-
{
89-
auto iter = mHistoricalSnapshots.find(*ledgerSeq);
90-
if (iter == mHistoricalSnapshots.end())
91-
{
92-
return std::nullopt;
93-
}
94-
95-
releaseAssert(iter->second);
96-
loopAllBuckets(loadKeysLoop, *iter->second);
97-
}
98-
99-
return entries;
100-
}
101-
10267
// This query has two steps:
10368
// 1. For each bucket, determine what PoolIDs contain the target asset via the
10469
// assetToPoolID index

0 commit comments

Comments
 (0)