[Bf-blender-cvs] [447378753d3] master: BLI: remove special cases for is_span and is_single methods

Jacques Lucke noreply at git.blender.org
Thu Nov 25 13:51:44 CET 2021


Commit: 447378753d320ea04d7c1ce00723fc02f35966f0
Author: Jacques Lucke
Date:   Thu Nov 25 13:51:23 2021 +0100
Branches: master
https://developer.blender.org/rB447378753d320ea04d7c1ce00723fc02f35966f0

BLI: remove special cases for is_span and is_single methods

Those were not implemented consistently and don't really help in practice.

===================================================================

M	source/blender/blenlib/BLI_virtual_array.hh
M	source/blender/functions/intern/generic_virtual_array.cc

===================================================================

diff --git a/source/blender/blenlib/BLI_virtual_array.hh b/source/blender/blenlib/BLI_virtual_array.hh
index b8b05e88572..33b3f82c0c2 100644
--- a/source/blender/blenlib/BLI_virtual_array.hh
+++ b/source/blender/blenlib/BLI_virtual_array.hh
@@ -719,9 +719,6 @@ template<typename T> class VArrayCommon {
   bool is_span() const
   {
     BLI_assert(*this);
-    if (this->is_empty()) {
-      return true;
-    }
     return impl_->is_span();
   }
 
@@ -742,9 +739,6 @@ template<typename T> class VArrayCommon {
   bool is_single() const
   {
     BLI_assert(*this);
-    if (impl_->size() == 1) {
-      return true;
-    }
     return impl_->is_single();
   }
 
diff --git a/source/blender/functions/intern/generic_virtual_array.cc b/source/blender/functions/intern/generic_virtual_array.cc
index 1fe1c2fc229..9df48818766 100644
--- a/source/blender/functions/intern/generic_virtual_array.cc
+++ b/source/blender/functions/intern/generic_virtual_array.cc
@@ -530,9 +530,6 @@ void GVArrayCommon::move_from(GVArrayCommon &&other) noexcept
 /* Returns true when the virtual array is stored as a span internally. */
 bool GVArrayCommon::is_span() const
 {
-  if (this->is_empty()) {
-    return true;
-  }
   return impl_->is_span();
 }
 
@@ -541,18 +538,12 @@ bool GVArrayCommon::is_span() const
 GSpan GVArrayCommon::get_internal_span() const
 {
   BLI_assert(this->is_span());
-  if (this->is_empty()) {
-    return GSpan(impl_->type());
-  }
   return impl_->get_internal_span();
 }
 
 /* Returns true when the virtual array returns the same value for every index. */
 bool GVArrayCommon::is_single() const
 {
-  if (impl_->size() == 1) {
-    return true;
-  }
   return impl_->is_single();
 }
 
@@ -562,10 +553,6 @@ bool GVArrayCommon::is_single() const
 void GVArrayCommon::get_internal_single(void *r_value) const
 {
   BLI_assert(this->is_single());
-  if (impl_->size() == 1) {
-    impl_->get(0, r_value);
-    return;
-  }
   impl_->get_internal_single(r_value);
 }



More information about the Bf-blender-cvs mailing list