diff options
| author | Yong He <yonghe@outlook.com> | 2021-02-04 13:50:51 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-02-04 13:50:51 -0800 |
| commit | c40f10b704b8bd5a744cc9b3964344585436b1ac (patch) | |
| tree | 1c9608f3cc32949d88fe04f3512cd3147fc3fe1f /source/core | |
| parent | 7f266f1ea7a51213069282296a905650fd405c3f (diff) | |
[gfx] Shader-object driven shader compilation. (#1688)
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-dictionary.h | 17 | ||||
| -rw-r--r-- | source/core/slang-short-list.h | 7 | ||||
| -rw-r--r-- | source/core/slang-smart-pointer.h | 6 |
3 files changed, 21 insertions, 9 deletions
diff --git a/source/core/slang-dictionary.h b/source/core/slang-dictionary.h index 4c352d55b..51b61de60 100644 --- a/source/core/slang-dictionary.h +++ b/source/core/slang-dictionary.h @@ -135,15 +135,17 @@ namespace Slang } }; - inline int GetHashPos(TKey& key) const + template<typename KeyType> + inline int GetHashPos(KeyType& key) const { SLANG_ASSERT(bucketSizeMinusOne > 0); const unsigned int hash = (unsigned int)getHashCode(key); return (hash * 2654435761u) % (unsigned int)(bucketSizeMinusOne); } - FindPositionResult FindPosition(const TKey& key) const + template<typename KeyType> + FindPositionResult FindPosition(const KeyType& key) const { - int hashPos = GetHashPos(const_cast<TKey&>(key)); + int hashPos = GetHashPos(const_cast<KeyType&>(key)); int insertPos = -1; int numProbes = 0; while (numProbes <= bucketSizeMinusOne) @@ -380,14 +382,16 @@ namespace Slang throw InvalidOperationException("Inconsistent find result returned. This is a bug in Dictionary implementation."); } - bool ContainsKey(const TKey& key) const + template<typename KeyType> + bool ContainsKey(const KeyType& key) const { if (bucketSizeMinusOne == -1) return false; auto pos = FindPosition(key); return pos.ObjectPosition != -1; } - bool TryGetValue(const TKey& key, TValue& value) const + template<typename KeyType> + bool TryGetValue(const KeyType& key, TValue& value) const { if (bucketSizeMinusOne == -1) return false; @@ -399,7 +403,8 @@ namespace Slang } return false; } - TValue* TryGetValue(const TKey& key) const + template<typename KeyType> + TValue* TryGetValue(const KeyType& key) const { if (bucketSizeMinusOne == -1) return nullptr; diff --git a/source/core/slang-short-list.h b/source/core/slang-short-list.h index 82ad4fe1e..7d51a8abf 100644 --- a/source/core/slang-short-list.h +++ b/source/core/slang-short-list.h @@ -47,6 +47,13 @@ namespace Slang return *this; } + ThisType& operator=(const ThisType& other) + { + clearAndDeallocate(); + addRange(other); + return *this; + } + ThisType& operator=(ThisType&& list) { // Could just do a swap here, and memory would be freed on rhs dtor diff --git a/source/core/slang-smart-pointer.h b/source/core/slang-smart-pointer.h index 53ac010ed..eb9fe7be5 100644 --- a/source/core/slang-smart-pointer.h +++ b/source/core/slang-smart-pointer.h @@ -114,9 +114,9 @@ namespace Slang template <typename U> RefPtr(RefPtr<U> const& p, typename EnableIf<IsConvertible<T*, U*>::Value, void>::type * = 0) - : pointer((U*) p) + : pointer(static_cast<U*>(p)) { - addReference((U*) p); + addReference(static_cast<U*>(p)); } #if 0 @@ -200,7 +200,7 @@ namespace Slang ~RefPtr() { - releaseReference((Slang::RefObject*) pointer); + releaseReference(static_cast<Slang::RefObject*>(pointer)); } T& operator*() const |
