mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 07:53:26 +00:00
Optimize clear
This commit is contained in:
parent
149a4b4ca1
commit
7685cb6f48
1 changed files with 7 additions and 5 deletions
|
@ -241,12 +241,14 @@ public:
|
|||
if (_keys == nullptr || _size == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t capacity = hash_table_size_primes[_capacity_idx];
|
||||
for (uint32_t i = 0; i < capacity; i++) {
|
||||
_hashes[i] = EMPTY_HASH;
|
||||
}
|
||||
for (uint32_t i = 0; i < _size; i++) {
|
||||
_keys[i].~TKey();
|
||||
memset(_hashes, EMPTY_HASH, sizeof(EMPTY_HASH) * capacity);
|
||||
|
||||
if constexpr (!std::is_trivially_destructible_v<TKey>) {
|
||||
for (uint32_t i = 0; i < _size; i++) {
|
||||
_keys[i].~TKey();
|
||||
}
|
||||
}
|
||||
|
||||
_size = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue