diff options
author | Jacques Lucke <jacques@blender.org> | 2022-04-07 20:28:41 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-04-07 20:28:41 +0300 |
commit | a5beca7ba0daaca81805dbbf8857378a5bde6414 (patch) | |
tree | 6706ff6ed48e3e9bc5288d40170f711cf2d7617b /source/blender/blenlib/BLI_index_range.hh | |
parent | 67c42e7f034aad2564d8cde1a9901d9629527daa (diff) |
BLI: inline fast path of IndexRange::as_span
This frequently showed up in profiling but shouldn't.
This also updates the code to use atomics for more correctness and
adds multi-threading for better performance.
Diffstat (limited to 'source/blender/blenlib/BLI_index_range.hh')
-rw-r--r-- | source/blender/blenlib/BLI_index_range.hh | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_index_range.hh b/source/blender/blenlib/BLI_index_range.hh index 85f2c83364b..7d5c2400bba 100644 --- a/source/blender/blenlib/BLI_index_range.hh +++ b/source/blender/blenlib/BLI_index_range.hh @@ -39,6 +39,7 @@ */ #include <algorithm> +#include <atomic> #include <cmath> #include <iostream> @@ -288,6 +289,12 @@ class IndexRange { stream << "[" << range.start() << ", " << range.one_after_last() << ")"; return stream; } + + private: + static std::atomic<int64_t> s_current_array_size; + static std::atomic<int64_t *> s_current_array; + + Span<int64_t> as_span_internal() const; }; } // namespace blender |