|
@@ -164,7 +164,8 @@ namespace Core {
|
|
|
return Error::NONE;
|
|
|
}
|
|
|
ProbingHashMap<K, V> map;
|
|
|
- int l = Core::Math::max(1 << Math::roundUpLog2(minCapacity), 8);
|
|
|
+ int l = static_cast<int>(Core::Math::max(
|
|
|
+ 1u << static_cast<u32>(Math::roundUpLog2(minCapacity)), 8u));
|
|
|
CORE_RETURN_ERROR(map.keys.resize(l, emptyValue<K>()));
|
|
|
map.values = reinterpret_cast<V*>(new AlignedType<V>[l]);
|
|
|
if(map.values == nullptr) {
|
|
@@ -281,11 +282,11 @@ namespace Core {
|
|
|
int rehashFactor = 2;
|
|
|
while(true) {
|
|
|
CORE_RETURN_ERROR(rehash(entries * rehashFactor + 1));
|
|
|
- int baseHash = static_cast<int>(hashCode(key) * 514685581u);
|
|
|
- int end = keys.getLength() - 1;
|
|
|
+ u32 baseHash = hashCode(key) * 514685581u;
|
|
|
+ u32 end = static_cast<u32>(keys.getLength()) - 1;
|
|
|
// rehash on bad clustering
|
|
|
- for(int i = 0; i <= 5; i++) {
|
|
|
- int hash = (baseHash + i) & end;
|
|
|
+ for(u32 i = 0; i <= 5; i++) {
|
|
|
+ int hash = static_cast<int>((baseHash + i) & end);
|
|
|
if(keys[hash] == emptyValue<K>() || keys[hash] == key) {
|
|
|
slot = hash;
|
|
|
return Core::Error::NONE;
|
|
@@ -297,10 +298,10 @@ namespace Core {
|
|
|
|
|
|
template<typename Value>
|
|
|
Value* searchValue(const K& key) const {
|
|
|
- int baseHash = static_cast<int>(hashCode(key) * 514685581u);
|
|
|
- int end = keys.getLength() - 1;
|
|
|
- for(int i = 0; i <= end; i++) [[unlikely]] {
|
|
|
- int hash = (baseHash + i) & end;
|
|
|
+ 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>()) {
|