From 4880789e3003441732cca4471091563f36531635 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 29 Apr 2019 17:03:46 -0400 Subject: String/List closer to conventions, and use Index type (#959) * List made members m_ Tweaked types to closer match conventions. * Use asserts for checking conditions on List. Other small improvements. * List.Count() -> getSize() * List Add -> add First -> getFirst Last -> getLast RemoveLast -> removeLast ReleaseBuffer -> detachBuffer GetArrayView -> getArrayView * List:: AddRange -> addRange Capacity -> getCapacity Insert -> insert InsertRange -> insertRange AddRange -> addRange RemoveRange -> removeRange RemoveAt -> removeAt Remove -> remove Reverse -> reverse FastRemove -> fastRemove FastRemoveAt -> fastRemoveAt Clear -> clear * List FreeBuffer -> _deallocateBuffer Free -> clearAndDeallocate SwapWith -> swapWith * List SetSize -> setSize Reserve -> reserve GrowToSize growToSize * UnsafeShrinkToSize -> unsafeShrinkToSize Compress -> compress FindLast -> findLastIndex FindLast -> findLastIndex Simplify Contains * List Removed m_allocator (wasn't used) Swap -> swapElements Sort -> sort Contains -> contains ForEach -> forEach QuickSort -> quickSort InsertionSort -> insertionSort BinarySearch -> binarySearch Max -> calcMax Min -> calcMin * Initializer::Initialize -> initialize List:: Allocate -> _allocate Init -> _init IndexOf -> indexOf * * Put #include in common.h, and remove unneeded inclusions * Small refactor of ArrayView - remove stride as not used * getSize -> getCount setSize -> setCount unsafeShrinkToSize->unsafeShrinkToCount growToSize -> growToCount m_size -> m_count * Some tidy up around Allocator. * Use Index type on List. * Refactor of IntSet. First tentative look at using Index. * Made Index an Int Did preliminary fixes. Made String use Index. * Partial refactor of String. * String::Buffer -> getBuffer ToWString -> toWString * Small improvements to String. String:: Buffer() -> getBuffer() Equals() -> equals * Try to use Index where appropriate. * Fix warnings on windows x86 builds. --- source/core/allocator.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'source/core/allocator.h') diff --git a/source/core/allocator.h b/source/core/allocator.h index 3306d3780..5832d0b84 100644 --- a/source/core/allocator.h +++ b/source/core/allocator.h @@ -8,7 +8,7 @@ namespace Slang { - inline void * AlignedAlloc(size_t size, size_t alignment) + inline void* alignedAllocate(size_t size, size_t alignment) { #ifdef _MSC_VER return _aligned_malloc(size, alignment); @@ -23,7 +23,7 @@ namespace Slang #endif } - inline void AlignedFree(void * ptr) + inline void alignedDeallocate(void* ptr) { #ifdef _MSC_VER _aligned_free(ptr); @@ -36,29 +36,29 @@ namespace Slang { public: // not really called - void * Alloc(size_t size) + void* allocate(size_t size) { - return malloc(size); + return ::malloc(size); } - void Free(void * ptr) + void deallocate(void * ptr) { - return free(ptr); + return ::free(ptr); } }; - template + template class AlignedAllocator { public: - void * Alloc(size_t size) + void* allocate(size_t size) { - return AlignedAlloc(size, alignment); + return alignedAllocate(size, ALIGNMENT); } - void Free(void * ptr) + void deallocate(void * ptr) { - return AlignedFree(ptr); + return alignedDeallocate(ptr); } }; } -#endif \ No newline at end of file +#endif -- cgit v1.2.3