From cf62f13cdc8a7f21c78f03b097bff6edf09fdead Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 6 Jul 2020 11:58:14 -0700 Subject: ShortList and core.natvis improvements. (#1430) * ShortList and core.natvis improvements. * Fix gcc build. * add `getBuffer()` accessor to `GetArrayViewResult` --- source/core/slang-list.h | 73 +++++------------------------------------------- 1 file changed, 7 insertions(+), 66 deletions(-) (limited to 'source/core/slang-list.h') diff --git a/source/core/slang-list.h b/source/core/slang-list.h index 28180ce4f..5c1e3cbc7 100644 --- a/source/core/slang-list.h +++ b/source/core/slang-list.h @@ -14,72 +14,6 @@ namespace Slang { - - template - class Initializer - { - - }; - - template - class Initializer - { - public: - static void initialize(T* buffer, int size) - { - for (int i = 0; i - class Initializer - { - public: - static void initialize(T* buffer, int size) - { - // It's pod so no initialization required - //for (int i = 0; i < size; i++) - // new (buffer + i) T; - } - }; - - template - class AllocateMethod - { - public: - static inline T* allocateArray(Index count) - { - TAllocator allocator; - T * rs = (T*)allocator.allocate(count * sizeof(T)); - Initializer::value>::initialize(rs, count); - return rs; - } - static inline void deallocateArray(T* ptr, Index count) - { - TAllocator allocator; - if (!std::is_trivially_destructible::value) - { - for (Index i = 0; i < count; i++) - ptr[i].~T(); - } - allocator.deallocate(ptr); - } - }; - - template - class AllocateMethod - { - public: - static inline T* allocateArray(Index count) - { - return new T[count]; - } - static inline void deallocateArray(T* ptr, Index /*bufferSize*/) - { - delete [] ptr; - } - }; - // List is container of values of a type held consecutively in memory (much like std::vector) // // Note that in this implementation, the underlying memory is backed via an allocation of T[capacity] @@ -102,6 +36,7 @@ namespace Slang } template List(const T& val, Args... args) + : m_buffer(nullptr), m_count(0), m_capacity(0) { _init(val, args...); } @@ -611,6 +546,10 @@ namespace Slang { return AllocateMethod::allocateArray(count); } + static void _free(T* buffer, Index count) + { + return AllocateMethod::deallocateArray(buffer, count); + } template void _init(const T& val, Args... args) @@ -618,6 +557,8 @@ namespace Slang add(val); _init(args...); } + + void _init() {} }; template -- cgit v1.2.3