Skip to content

Commit d12f927

Browse files
Adrien Béraudaberaud
authored andcommitted
pht: use const reference for IndexEntry::TYPE
Prevents static initialization order issue
1 parent 3639d65 commit d12f927

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/opendht/indexation/pht.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ ee *
266266

267267
using Value = std::pair<InfoHash, dht::Value::Id>;
268268
struct OPENDHT_PUBLIC IndexEntry : public dht::Value::Serializable<IndexEntry> {
269-
static const ValueType TYPE;
269+
static const ValueType& TYPE;
270270

271271
virtual void unpackValue(const dht::Value& v) {
272272
Serializable<IndexEntry>::unpackValue(v);

src/indexation/pht.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ int Pht::Cache::lookup(const Prefix& p) {
145145
return pos;
146146
}
147147

148-
const ValueType IndexEntry::TYPE = ValueType::USER_DATA;
148+
const ValueType& IndexEntry::TYPE = ValueType::USER_DATA;
149149
constexpr std::chrono::minutes Pht::Cache::NODE_EXPIRE_TIME;
150150

151151
void Pht::lookupStep(Prefix p, std::shared_ptr<int> lo, std::shared_ptr<int> hi,

0 commit comments

Comments
 (0)