|
@@ -298,14 +298,16 @@ namespace Core {
|
|
|
|
|
|
template<typename Value>
|
|
|
Value* searchValue(const K& key) const {
|
|
|
- u32 baseHash = hashCode(key) * 514685581u;
|
|
|
- u32 end = static_cast<u32>(keys.getLength()) - 1;
|
|
|
- for(u32 i = 0; i <= end; i++) [[unlikely]] {
|
|
|
- int hash = static_cast<int>((baseHash + i) & end);
|
|
|
- if(keys[hash] == key) [[likely]] {
|
|
|
- return values + hash;
|
|
|
- } else if(keys[hash] == emptyValue<K>()) {
|
|
|
- return nullptr;
|
|
|
+ if(keys.getLength() != 0) {
|
|
|
+ u32 baseHash = hashCode(key) * 514685581u;
|
|
|
+ u32 end = static_cast<u32>(keys.getLength()) - 1;
|
|
|
+ for(u32 i = 0; i <= end; i++) [[unlikely]] {
|
|
|
+ int hash = static_cast<int>((baseHash + i) & end);
|
|
|
+ if(keys[hash] == key) [[likely]] {
|
|
|
+ return values + hash;
|
|
|
+ } else if(keys[hash] == emptyValue<K>()) {
|
|
|
+ return nullptr;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
return nullptr;
|