diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2018-09-19 15:27:50 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-19 15:27:50 -0400 |
| commit | 653fe976af88fcf86162ca5bb1b46d4378864572 (patch) | |
| tree | 882307a3377e6a4587231721d681daa061a56c78 /source/core/hash.h | |
| parent | a37b3539d94c434c5d74ab524eae2988e48e0756 (diff) | |
Support for IRStringLit (#645)
* * Added support for strings in IR with IRStringLit - with storage of chars after it
* Added kIRDecorationOp_Transitory - can be used for detecting instructions constructed on stack
* Made IRConstant hashing work off type
* Fix comment that is out of date about how an instruction is determines to hold a transitory string.
Diffstat (limited to 'source/core/hash.h')
| -rw-r--r-- | source/core/hash.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/source/core/hash.h b/source/core/hash.h index 26450029d..ca6172fc7 100644 --- a/source/core/hash.h +++ b/source/core/hash.h @@ -34,7 +34,16 @@ namespace Slang { return GetHashCode(const_cast<const char *>(buffer)); } - + inline int GetHashCode(const char * buffer, size_t numChars) + { + int hash = 0; + for (size_t i = 0; i < numChars; ++i) + { + hash = int(buffer[i]) + (hash << 6) + (hash << 16) - hash; + } + return hash; + } + template<int IsInt> class Hash { |
