diff options
author | Jacques Lucke <jacques@blender.org> | 2020-07-20 13:16:20 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2020-07-20 13:16:20 +0300 |
commit | 8cbbdedaf4dfec9e320e7e2be58b75d256950df1 (patch) | |
tree | 496b9620e11ac44e515b0bb4ca52c05834d557f9 /source/blender/blenlib/intern/BLI_index_range.cc | |
parent | 686ab4c9401a90b22fb17e46c992eb513fe4f693 (diff) |
Refactor: Update integer type usage
This updates the usage of integer types in code I wrote according to our new style guides.
Major changes:
* Use signed instead of unsigned integers in many places.
* C++ containers in blenlib use `int64_t` for size and indices now (instead of `uint`).
* Hash values for C++ containers are 64 bit wide now (instead of 32 bit).
I do hope that I broke no builds, but it is quite likely that some compiler reports
slightly different errors. Please let me know when there are any errors. If the fix
is small, feel free to commit it yourself.
I compiled successfully on linux with gcc and on windows.
Diffstat (limited to 'source/blender/blenlib/intern/BLI_index_range.cc')
-rw-r--r-- | source/blender/blenlib/intern/BLI_index_range.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/blenlib/intern/BLI_index_range.cc b/source/blender/blenlib/intern/BLI_index_range.cc index 9fa19143f91..a906416b491 100644 --- a/source/blender/blenlib/intern/BLI_index_range.cc +++ b/source/blender/blenlib/intern/BLI_index_range.cc @@ -24,28 +24,28 @@ namespace blender { -static Vector<Array<uint, 0, RawAllocator>, 1, RawAllocator> arrays; -static uint current_array_size = 0; -static uint *current_array = nullptr; +static Vector<Array<int64_t, 0, RawAllocator>, 1, RawAllocator> arrays; +static int64_t current_array_size = 0; +static int64_t *current_array = nullptr; static std::mutex current_array_mutex; -Span<uint> IndexRange::as_span() const +Span<int64_t> IndexRange::as_span() const { - uint min_required_size = start_ + size_; + int64_t min_required_size = start_ + size_; if (min_required_size <= current_array_size) { - return Span<uint>(current_array + start_, size_); + return Span<int64_t>(current_array + start_, size_); } std::lock_guard<std::mutex> lock(current_array_mutex); if (min_required_size <= current_array_size) { - return Span<uint>(current_array + start_, size_); + return Span<int64_t>(current_array + start_, size_); } - uint new_size = std::max<uint>(1000, power_of_2_max_u(min_required_size)); - Array<uint, 0, RawAllocator> new_array(new_size); - for (uint i = 0; i < new_size; i++) { + int64_t new_size = std::max<int64_t>(1000, power_of_2_max_u(min_required_size)); + Array<int64_t, 0, RawAllocator> new_array(new_size); + for (int64_t i = 0; i < new_size; i++) { new_array[i] = i; } arrays.append(std::move(new_array)); @@ -54,7 +54,7 @@ Span<uint> IndexRange::as_span() const std::atomic_thread_fence(std::memory_order_seq_cst); current_array_size = new_size; - return Span<uint>(current_array + start_, size_); + return Span<int64_t>(current_array + start_, size_); } } // namespace blender |