Put the next link at the end to allow closer packing if alignment allows.
@@ -50,7 +50,7 @@ namespace vespalib {
class hashtable_base
{
public:
- typedef unsigned int next_t;
+ using next_t = uint32_t;
/**
* This is a standard modulator that does modulo/hashTableSize.
* Hashtable size is selected from a a set of prime numbers.
@@ -98,11 +98,11 @@ class hash_node {
public:
using next_t=hashtable_base::next_t;
enum {npos=-1u, invalid=-2u};
- hash_node() : _next(invalid) {}
+ hash_node() : _node(), _next(invalid) {}
hash_node(const V & node, next_t next=npos)
- : _next(next), _node(node) {}
+ : _node(node), _next(next) {}
hash_node(V &&node, next_t next=npos)
- : _next(next), _node(std::move(node)) {}
+ : _node(std::move(node)), _next(next) {}
hash_node(hash_node &&) noexcept = default;
hash_node &operator=(hash_node &&) noexcept = default;
hash_node(const hash_node &) = default; // These will not be created
@@ -119,8 +119,8 @@ public:
bool valid() const { return _next != invalid; }
bool hasNext() const { return valid() && (_next != npos); }
private:
- next_t _next;
V _node;
+ next_t _next;
};
template< typename Key, typename Value, typename Hash, typename Equal, typename KeyExtract, typename Modulator = hashtable_base::prime_modulator>
