putil: Fix SimpleHashMap error reporting at static init time

This commit is contained in:
rdb 2023-02-12 13:49:44 +01:00
parent a9e9cfae1c
commit 914993f31b

View File

@ -532,11 +532,10 @@ validate() const {
size_t index = (size_t)index_array[slot]; size_t index = (size_t)index_array[slot];
++count; ++count;
if (index >= _num_entries) { if (index >= _num_entries) {
util_cat.error() write(util_cat->error()
<< "SimpleHashMap " << this << " is invalid: slot " << slot << "SimpleHashMap " << this << " is invalid: slot " << slot
<< " contains index " << index << " which is past the end of the" << " contains index " << index << " which is past the end of the"
" table\n"; " table\n");
write(util_cat.error(false));
return false; return false;
} }
nassertd(index < _num_entries) continue; nassertd(index < _num_entries) continue;
@ -546,21 +545,19 @@ validate() const {
wants_slot = next_hash(wants_slot); wants_slot = next_hash(wants_slot);
} }
if (wants_slot != slot) { if (wants_slot != slot) {
util_cat.error() write(util_cat->error()
<< "SimpleHashMap " << this << " is invalid: key " << "SimpleHashMap " << this << " is invalid: key "
<< _table[index]._key << " should be in slot " << wants_slot << _table[index]._key << " should be in slot " << wants_slot
<< " instead of " << slot << " (ideal is " << ideal_slot << ")\n"; << " instead of " << slot << " (ideal is " << ideal_slot << ")\n");
write(util_cat.error(false));
return false; return false;
} }
} }
} }
if (count != _num_entries) { if (count != _num_entries) {
util_cat.error() write(util_cat->error()
<< "SimpleHashMap " << this << " is invalid: reports " << _num_entries << "SimpleHashMap " << this << " is invalid: reports " << _num_entries
<< " entries, actually has " << count << "\n"; << " entries, actually has " << count << "\n");
write(util_cat.error(false));
return false; return false;
} }