diff options
author | Francis Dupont <fdupont@isc.org> | 2020-06-20 13:54:08 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2020-07-23 21:07:51 +0200 |
commit | 392d1e5926cf46d3a6c81a8858f06b1ac5d86d87 (patch) | |
tree | 86c1eb1a75174292d840f633525a9917212c1092 /src/lib/asiolink/io_address.cc | |
parent | [#1283] Added (and used) IOAddress hash (diff) | |
download | kea-392d1e5926cf46d3a6c81a8858f06b1ac5d86d87.tar.xz kea-392d1e5926cf46d3a6c81a8858f06b1ac5d86d87.zip |
[#1283] Optimized hash
Diffstat (limited to 'src/lib/asiolink/io_address.cc')
-rw-r--r-- | src/lib/asiolink/io_address.cc | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/asiolink/io_address.cc b/src/lib/asiolink/io_address.cc index a9eb587c33..a2a0a788cc 100644 --- a/src/lib/asiolink/io_address.cc +++ b/src/lib/asiolink/io_address.cc @@ -173,10 +173,15 @@ IOAddress::increase(const IOAddress& addr) { return (IOAddress::fromBytes(addr.getFamily(), &packed[0])); } -std::size_t +size_t hash_value(const IOAddress& address) { - boost::hash<std::vector<uint8_t> > hasher; - return (hasher(address.toBytes())); + if (address.isV4()) { + boost::hash<uint32_t> hasher; + return (hasher(address.toUint32())); + } else { + boost::hash<std::vector<uint8_t> > hasher; + return (hasher(address.toBytes())); + } } } // namespace asiolink |