From 5df582dd3229789364ae3fa75575fd978ca3282d Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 4 Dec 2019 12:38:38 -0500 Subject: Feature/string hash review (#1142) * * Added ConstArrayView * Made StringSlicePool have styles * Remove point about strings not having terminating 0 (they do), and restriction around "" * spCalcStringHash -> spComputeStringHash * Small code improvements. Closer to coding conventions. * Fix small bug with Empty adding c string. * Fix typo in assert. * Fix ArrayView compiling issue on gcc/clang. * Remove tabs. * Improve comments around StringSlicePool. Simplify getting the added slices. --- source/slang/slang-reflection.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-reflection.cpp') diff --git a/source/slang/slang-reflection.cpp b/source/slang/slang-reflection.cpp index 306c45c14..8901f6bdd 100644 --- a/source/slang/slang-reflection.cpp +++ b/source/slang/slang-reflection.cpp @@ -1504,7 +1504,8 @@ SLANG_API SlangUInt spReflection_getHashedStringCount( SlangReflection* reflection) { auto programLayout = convert(reflection); - return programLayout->hashedStringLiteralPool.getNumSlices() - StringSlicePool::kNumDefaultHandles; + auto slices = programLayout->hashedStringLiteralPool.getAdded(); + return slices.getCount(); } SLANG_API const char* spReflection_getHashedString( @@ -1513,12 +1514,15 @@ SLANG_API const char* spReflection_getHashedString( size_t* outCount) { auto programLayout = convert(reflection); - UnownedStringSlice slice = programLayout->hashedStringLiteralPool.getSlice(StringSlicePool::Handle(index + StringSlicePool::kNumDefaultHandles)); + + auto slices = programLayout->hashedStringLiteralPool.getAdded(); + auto slice = slices[Index(index)]; + *outCount = slice.size(); return slice.begin(); } -SLANG_API int spCalcStringHash(const char* chars, size_t count) +SLANG_API int spComputeStringHash(const char* chars, size_t count) { UnownedStringSlice slice(chars, count); return GetHashCode(slice); -- cgit v1.2.3