Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <jacques@blender.org>2022-04-06 17:13:37 +0300
committerJacques Lucke <jacques@blender.org>2022-04-06 17:13:37 +0300
commitcf059c950e65039216f0bf700bddace948de2a7a (patch)
treefdb17b109529e961d652b6700d36fa55ea3b141e
parentb21856dbeea82db46155afd5f83fb07a2fedcc56 (diff)
-rw-r--r--source/blender/blenlib/BLI_virtual_array.hh84
1 files changed, 43 insertions, 41 deletions
diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh
index 56476a2e52b..5ff1200e650 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -154,27 +154,11 @@ template<typename T> class VArrayImpl {
virtual void materialize_compressed(IndexMask mask, MutableSpan<T> r_span) const
{
BLI_assert(mask.size() == r_span.size());
- T *dst = r_span.data();
- /* Optimize for a few different common cases. */
- if (this->is_span()) {
- const T *src = this->get_internal_span().data();
- mask.to_best_mask_type([&](auto best_mask) {
- for (const int64_t i : IndexRange(best_mask.size())) {
- dst[i] = src[best_mask[i]];
- }
- });
- }
- else if (this->is_single()) {
- const T single = this->get_internal_single();
- r_span.fill(single);
- }
- else {
- mask.to_best_mask_type([&](auto best_mask) {
- for (const int64_t i : IndexRange(best_mask.size())) {
- dst[i] = this->get(best_mask[i]);
- }
- });
- }
+ mask.to_best_mask_type([&](auto best_mask) {
+ for (const int64_t i : IndexRange(best_mask.size())) {
+ r_span[i] = this->get(best_mask[i]);
+ }
+ });
}
/**
@@ -184,26 +168,11 @@ template<typename T> class VArrayImpl {
{
BLI_assert(mask.size() == r_span.size());
T *dst = r_span.data();
- /* Optimize for a few different common cases. */
- if (this->is_span()) {
- const T *src = this->get_internal_span().data();
- mask.to_best_mask_type([&](auto best_mask) {
- for (const int64_t i : IndexRange(best_mask.size())) {
- new (dst + i) T(src[best_mask[i]]);
- }
- });
- }
- else if (this->is_single()) {
- const T single = this->get_internal_single();
- uninitialized_fill_n(dst, mask.size(), single);
- }
- else {
- mask.to_best_mask_type([&](auto best_mask) {
- for (const int64_t i : IndexRange(best_mask.size())) {
- new (dst + i) T(this->get(best_mask[i]));
- }
- });
- }
+ mask.to_best_mask_type([&](auto best_mask) {
+ for (const int64_t i : IndexRange(best_mask.size())) {
+ new (dst + i) T(this->get(best_mask[i]));
+ }
+ });
}
/**
@@ -325,6 +294,25 @@ template<typename T> class VArrayImpl_For_Span : public VMutableArrayImpl<T> {
const Span<T> other_span = other.get_internal_span();
return data_ == other_span.data();
}
+
+ void materialize_compressed(IndexMask mask, MutableSpan<T> r_span) const
+ {
+ mask.to_best_mask_type([&](auto best_mask) {
+ for (const int64_t i : IndexRange(best_mask.size())) {
+ r_span[i] = data_[best_mask[i]];
+ }
+ });
+ }
+
+ void materialize_compressed_to_uninitialized(IndexMask mask, MutableSpan<T> r_span) const
+ {
+ T *dst = r_span.data();
+ mask.to_best_mask_type([&](auto best_mask) {
+ for (const int64_t i : IndexRange(best_mask.size())) {
+ new (dst + i) T(data_[best_mask[i]]);
+ }
+ });
+ }
};
/**
@@ -401,6 +389,20 @@ template<typename T> class VArrayImpl_For_Single final : public VArrayImpl<T> {
{
return value_;
}
+
+ void materialize_compressed(IndexMask mask, MutableSpan<T> r_span) const override
+ {
+ BLI_assert(mask.size() == r_span.size());
+ UNUSED_VARS_NDEBUG(mask);
+ r_span.fill(value_);
+ }
+
+ void materialize_compressed_to_uninitialized(IndexMask mask,
+ MutableSpan<T> r_span) const override
+ {
+ BLI_assert(mask.size() == r_span.size());
+ uninitialized_fill_n(r_span.data(), mask.size(), value_);
+ }
};
/**