diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/hash.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/source/core/hash.h b/source/core/hash.h index ca6172fc7..fc0bca737 100644 --- a/source/core/hash.h +++ b/source/core/hash.h @@ -43,7 +43,18 @@ namespace Slang } return hash; } - + + inline uint64_t GetHashCode64(const char * buffer, size_t numChars) + { + // Use uints because hash requires wrap around behavior and int is undefined on over/underflows + uint64_t hash = 0; + for (size_t i = 0; i < numChars; ++i) + { + hash = uint64_t(int64_t(buffer[i])) + (hash << 6) + (hash << 16) - hash; + } + return hash; + } + template<int IsInt> class Hash { @@ -111,4 +122,4 @@ namespace Slang } } -#endif
\ No newline at end of file +#endif |
