diff options
Diffstat (limited to 'source/core/slang-dictionary.h')
| -rw-r--r-- | source/core/slang-dictionary.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/source/core/slang-dictionary.h b/source/core/slang-dictionary.h index be7cc21f5..72b24f81c 100644 --- a/source/core/slang-dictionary.h +++ b/source/core/slang-dictionary.h @@ -54,11 +54,11 @@ namespace Slang Value = that.Value; return *this; } - int GetHashCode() + HashCode getHashCode() { return combineHash( - Slang::GetHashCode(Key), - Slang::GetHashCode(Value)); + Slang::getHashCode(Key), + Slang::getHashCode(Value)); } bool operator==(const KeyValuePair<TKey, TValue>& that) const { @@ -135,8 +135,10 @@ namespace Slang }; inline int GetHashPos(TKey& key) const - { - return ((unsigned int)(GetHashCode(key) * 2654435761)) % bucketSizeMinusOne; + { + SLANG_ASSERT(bucketSizeMinusOne > 0); + const unsigned int hash = (unsigned int)getHashCode(key); + return (hash * 2654435761u) % (unsigned int)(bucketSizeMinusOne); } FindPositionResult FindPosition(const TKey& key) const { @@ -166,7 +168,7 @@ namespace Slang } if (insertPos != -1) return FindPositionResult(-1, insertPos); - throw InvalidOperationException("Hash map is full. This indicates an error in Key::Equal or Key::GetHashCode."); + throw InvalidOperationException("Hash map is full. This indicates an error in Key::Equal or Key::getHashCode."); } TValue & _Insert(KeyValuePair<TKey, TValue>&& kvPair, int pos) { |
