diff options
author | Jacques Lucke <jacques@blender.org> | 2022-09-07 14:15:34 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2022-09-07 14:15:34 +0300 |
commit | 967664d1ee2f40a85301b1a8ccdb0ba3fe811d5d (patch) | |
tree | d7cf7195b8f7a855c20ca058613d5d8b211d18ee /source/blender/blenlib/BLI_index_range.hh | |
parent | 13a7516f436597e7f60d0696afa16e8e6d6735fb (diff) |
BLI: new C++ BitVector data structure
This adds a new `blender::BitVector` data structure that was requested
a couple of times. It also replaces usages of `BLI_bitmap` in C++ code.
See the comment in `BLI_bit_vector.hh` for more details about the
advantages and disadvantages of using a bit-vector and how the new
data structure compares to `std::vector<bool>` and `BLI_bitmap`.
Differential Revision: https://developer.blender.org/D14006
Diffstat (limited to 'source/blender/blenlib/BLI_index_range.hh')
-rw-r--r-- | source/blender/blenlib/BLI_index_range.hh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/source/blender/blenlib/BLI_index_range.hh b/source/blender/blenlib/BLI_index_range.hh index 2b290e1ba7d..a0f129c7324 100644 --- a/source/blender/blenlib/BLI_index_range.hh +++ b/source/blender/blenlib/BLI_index_range.hh @@ -318,4 +318,19 @@ class IndexRange { Span<int64_t> as_span_internal() const; }; +struct AlignedIndexRanges { + IndexRange prefix; + IndexRange aligned; + IndexRange suffix; +}; + +/** + * Split a range into three parts so that the boundaries of the middle part are aligned to some + * power of two. + * + * This can be used when an algorithm can be optimized on aligned indices/memory. The algorithm + * then needs a slow path for the beginning and end, and a fast path for the aligned elements. + */ +AlignedIndexRanges split_index_range_by_alignment(const IndexRange range, const int64_t alignment); + } // namespace blender |