diff options
author | Jacques Lucke <jacques@blender.org> | 2020-06-09 12:58:47 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-06-09 12:58:47 +0300 |
commit | f7c0f1b8b83ac475755b633abf59cf9f447b2d49 (patch) | |
tree | 97302f741ce4e40f6e4de9f0cfd54c7320ee7fd5 /source/blender/blenlib/BLI_stack.hh | |
parent | 7d2b4ae9c6ecce394130cd08694914bf93497a11 (diff) |
BLI: rename ArrayRef to Span
This also renames `MutableArrayRef` to `MutableSpan`.
The name "Span" works better, because `std::span` will provide
similar functionality in C++20. Furthermore, a shorter, more
concise name for a common data structure is nice.
Diffstat (limited to 'source/blender/blenlib/BLI_stack.hh')
-rw-r--r-- | source/blender/blenlib/BLI_stack.hh | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_stack.hh b/source/blender/blenlib/BLI_stack.hh index 81b8b192efd..030d9c84c8e 100644 --- a/source/blender/blenlib/BLI_stack.hh +++ b/source/blender/blenlib/BLI_stack.hh @@ -41,8 +41,8 @@ */ #include "BLI_allocator.hh" -#include "BLI_array_ref.hh" #include "BLI_memory_utils.hh" +#include "BLI_span.hh" namespace blender { @@ -139,7 +139,7 @@ class Stack { * Create a new stack that contains the given elements. The values are pushed to the stack in * the order they are in the array. */ - Stack(ArrayRef<T> values) : Stack() + Stack(Span<T> values) : Stack() { this->push_multiple(values); } @@ -153,7 +153,7 @@ class Stack { * assert(stack.pop() == 6); * assert(stack.pop() == 5); */ - Stack(const std::initializer_list<T> &values) : Stack(ArrayRef<T>(values)) + Stack(const std::initializer_list<T> &values) : Stack(Span<T>(values)) { } @@ -162,7 +162,7 @@ class Stack { for (const Chunk *chunk = &other.m_inline_chunk; chunk; chunk = chunk->above) { const T *begin = chunk->begin; const T *end = (chunk == other.m_top_chunk) ? other.m_top : chunk->capacity_end; - this->push_multiple(ArrayRef<T>(begin, end - begin)); + this->push_multiple(Span<T>(begin, end - begin)); } } @@ -289,9 +289,9 @@ class Stack { * This method is more efficient than pushing multiple elements individually and might cause less * heap allocations. */ - void push_multiple(ArrayRef<T> values) + void push_multiple(Span<T> values) { - ArrayRef<T> remaining_values = values; + Span<T> remaining_values = values; while (!remaining_values.is_empty()) { if (m_top == m_top_chunk->capacity_end) { this->activate_next_chunk(remaining_values.size()); |