Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

`AHashMap`: Skip look-up if map was allocated but cleared

DeeJayLSPff83bb4aaeee
diff --git a/core/templates/a_hash_map.h b/core/templates/a_hash_map.h
index b82318f1758..00b0b0c6739 100644
--- a/core/templates/a_hash_map.h
+++ b/core/templates/a_hash_map.h
@@ -97,15 +97,15 @@ private:
}
bool _lookup_idx(const TKey &p_key, uint32_t &r_element_idx, uint32_t &r_meta_idx) const {
- if (unlikely(_elements == nullptr)) {
- return false; // Failed lookups, no _elements.
+ if (unlikely(_size == 0)) {
+ return false; // Failed lookups, size is 0.
}
return _lookup_idx_with_hash(p_key, r_element_idx, r_meta_idx, _hash(p_key));
}
bool _lookup_idx_with_hash(const TKey &p_key, uint32_t &r_element_idx, uint32_t &r_meta_idx, uint32_t p_hash) const {
- if (unlikely(_elements == nullptr)) {
- return false; // Failed lookups, no _elements.
+ if (unlikely(_size == 0)) {
+ return false; // Failed lookups, size is 0.
}
uint32_t meta_idx = p_hash & _capacity_mask;