MCPcopy Create free account
hub / github.com/bytedance/Fastbot_Android / EnumDistanceImpl

Function EnumDistanceImpl

native/thirdpart/flatbuffers/idl_parser.cpp:2102–2107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2100}
2101
2102template<typename T> static uint64_t EnumDistanceImpl(T e1, T e2) {
2103 if (e1 < e2) { std::swap(e1, e2); } // use std for scalars
2104 // Signed overflow may occur, use unsigned calculation.
2105 // The unsigned overflow is well-defined by C++ standard (modulo 2^n).
2106 return static_cast<uint64_t>(e1) - static_cast<uint64_t>(e2);
2107}
2108
2109uint64_t EnumDef::Distance(const EnumVal *v1, const EnumVal *v2) const {
2110 return IsUInt64() ? EnumDistanceImpl(v1->GetAsUInt64(), v2->GetAsUInt64())

Callers 1

DistanceMethod · 0.85

Calls 1

swapFunction · 0.70

Tested by

no test coverage detected