MCPcopy Create free account
hub / github.com/bytedance/bolt / safeMul

Function safeMul

bolt/exec/HashTable.cpp:1497–1507  ·  view source on GitHub ↗

Multiplies a * b and produces uint64_t max to denote overflow. If either a or b is overflow, preserves overflow.

Source from the content-addressed store, hash-verified

1495// Multiplies a * b and produces uint64_t max to denote overflow. If
1496// either a or b is overflow, preserves overflow.
1497inline uint64_t safeMul(uint64_t a, uint64_t b) {
1498 constexpr uint64_t kMax = std::numeric_limits<uint64_t>::max();
1499 if (a == kMax || b == kMax) {
1500 return kMax;
1501 }
1502 uint64_t result;
1503 if (__builtin_mul_overflow(a, b, &result)) {
1504 return kMax;
1505 }
1506 return result;
1507}
1508} // namespace
1509
1510template <bool ignoreNullKeys>

Callers 2

enableRangeWhereCanMethod · 0.85
decideHashModeMethod · 0.85

Calls 1

maxFunction · 0.50

Tested by

no test coverage detected