xor fast hash storage: reorder initialization of elements, delete default c'tor, resetting of table may be expensive as it is rare

This commit is contained in:
Dennis Luxen 2015-01-14 18:14:55 +01:00
parent 39edbcbabd
commit 527e6cbc72

View File

@ -47,13 +47,15 @@ template <typename NodeID, typename Key> class XORFastHashStorage
{
}
HashCell(const HashCell &other) : key(other.key), id(other.id), time(other.time) {}
HashCell(const HashCell &other) : time(other.key), id(other.id), key(other.time) {}
operator Key() const { return key; }
void operator=(const Key key_to_insert) { key = key_to_insert; }
};
XORFastHashStorage() = delete;
explicit XORFastHashStorage(size_t) : positions(2 << 16), current_timestamp(0) {}
HashCell &operator[](const NodeID node)
@ -86,12 +88,11 @@ template <typename NodeID, typename Key> class XORFastHashStorage
if (std::numeric_limits<unsigned>::max() == current_timestamp)
{
positions.clear();
// positions.resize((2 << 16));
positions.resize(2 << 16);
}
}
private:
XORFastHashStorage() : positions(2 << 16), current_timestamp(0) {}
std::vector<HashCell> positions;
XORFastHash fast_hasher;
unsigned current_timestamp;