! * \brief Calculate the power-of-2 table size given the lower-bound of required capacity. * \param cap The lower-bound of the required capacity * \param fib_shift The result shift for Fibonacci Hashing * \param n_slots The result number of slots */
| 915 | * \param n_slots The result number of slots |
| 916 | */ |
| 917 | static void CalcTableSize(uint64_t cap, uint32_t* fib_shift, uint64_t* n_slots) { |
| 918 | uint32_t shift = 64; |
| 919 | uint64_t slots = 1; |
| 920 | for (uint64_t c = cap; c; c >>= 1) { |
| 921 | shift -= 1; |
| 922 | slots <<= 1; |
| 923 | } |
| 924 | TVM_FFI_ICHECK_GT(slots, cap); |
| 925 | if (slots < cap * 2) { |
| 926 | *fib_shift = shift - 1; |
| 927 | *n_slots = slots << 1; |
| 928 | } else { |
| 929 | *fib_shift = shift; |
| 930 | *n_slots = slots; |
| 931 | } |
| 932 | } |
| 933 | /*! |
| 934 | * \brief Fibonacci Hashing, maps a hash code to an index in a power-of-2-sized table. |
| 935 | * See also: https://programmingpraxis.com/2018/06/19/fibonacci-hash/. |
nothing calls this directly
no outgoing calls
no test coverage detected