MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / calcNumBytesTotal

Method calcNumBytesTotal

libCacheSim/dataStructure/robin_hood.h:2144–2161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2142
2143 // calculation only allowed for 2^n values
2144 ROBIN_HOOD(NODISCARD) size_t calcNumBytesTotal(size_t numElements) const {
2145#if ROBIN_HOOD(BITNESS) == 64
2146 return numElements * sizeof(Node) + calcNumBytesInfo(numElements);
2147#else
2148 // make sure we're doing 64bit operations, so we are at least safe against 32bit overflows.
2149 auto const ne = static_cast<uint64_t>(numElements);
2150 auto const s = static_cast<uint64_t>(sizeof(Node));
2151 auto const infos = static_cast<uint64_t>(calcNumBytesInfo(numElements));
2152
2153 auto const total64 = ne * s + infos;
2154 auto const total = static_cast<size_t>(total64);
2155
2156 if (ROBIN_HOOD_UNLIKELY(static_cast<uint64_t>(total) != total64)) {
2157 throwOverflowError();
2158 }
2159 return total;
2160#endif
2161 }
2162
2163 private:
2164 template <typename Q = mapped_type>

Callers 1

operator()Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected