diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/hash.h | 11 | ||||
| -rw-r--r-- | source/core/slang-string.h | 5 |
2 files changed, 15 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 { diff --git a/source/core/slang-string.h b/source/core/slang-string.h index 2609b37ab..df1055795 100644 --- a/source/core/slang-string.h +++ b/source/core/slang-string.h @@ -717,6 +717,11 @@ namespace Slang { return Slang::GetHashCode((const char*)begin()); } + + UnownedStringSlice getUnownedSlice() const + { + return StringRepresentation::asSlice(buffer); + } }; class StringBuilder : public String |
