Added explanatory comment about integer constants.

pull/13171/head
Joshua Haberman 4 years ago
parent f2d826b9f3
commit 8113ebd6c7
  1. 1
      upb/table.c

@ -294,6 +294,7 @@ static bool streql(upb_tabkey k1, lookupkey_t k2) {
bool upb_strtable_init2(upb_strtable *t, upb_ctype_t ctype, bool upb_strtable_init2(upb_strtable *t, upb_ctype_t ctype,
size_t expected_size, upb_alloc *a) { size_t expected_size, upb_alloc *a) {
UPB_UNUSED(ctype); /* TODO(haberman): rm */ UPB_UNUSED(ctype); /* TODO(haberman): rm */
// Multiply by approximate reciprocal of MAX_LOAD (0.85), with pow2 denominator.
size_t need_entries = (expected_size + 1) * 1204 / 1024; size_t need_entries = (expected_size + 1) * 1204 / 1024;
UPB_ASSERT(need_entries >= expected_size * 0.85); UPB_ASSERT(need_entries >= expected_size * 0.85);
int size_lg2 = _upb_lg2ceil(need_entries); int size_lg2 = _upb_lg2ceil(need_entries);

Loading…
Cancel
Save