diff --git a/source/blender/blenkernel/intern/mesh_validate.cc b/source/blender/blenkernel/intern/mesh_validate.cc index f6197e7d6f3..23d339ff391 100644 --- a/source/blender/blenkernel/intern/mesh_validate.cc +++ b/source/blender/blenkernel/intern/mesh_validate.cc @@ -1185,7 +1185,7 @@ void strip_loose_faces_corners(Mesh *mesh, blender::BitSpan faces_to_remove) } else { /* If one of the face's corners is invalid, the whole face is invalid! */ - if (corner_edges.slice(start, size).as_span().contains(INVALID_CORNER_EDGE_MARKER)) { + if (corner_edges.slice(start, size).contains(INVALID_CORNER_EDGE_MARKER)) { invalid = true; } } diff --git a/source/blender/blenlib/BLI_span.hh b/source/blender/blenlib/BLI_span.hh index 0c316ef7d02..9323a30dfab 100644 --- a/source/blender/blenlib/BLI_span.hh +++ b/source/blender/blenlib/BLI_span.hh @@ -709,6 +709,20 @@ template class MutableSpan { return counter; } + /** + * Does a linear search to see of the value is in the array. + * Returns true if it is, otherwise false. + */ + constexpr bool contains(const T &value) const + { + for (const T &element : *this) { + if (element == value) { + return true; + } + } + return false; + } + /** * Does a constant time check to see if the pointer points to a value in the referenced array. * Return true if it is, otherwise false. diff --git a/source/blender/blenlib/tests/BLI_span_test.cc b/source/blender/blenlib/tests/BLI_span_test.cc index 92af8d0704d..2354933e9f4 100644 --- a/source/blender/blenlib/tests/BLI_span_test.cc +++ b/source/blender/blenlib/tests/BLI_span_test.cc @@ -168,6 +168,18 @@ TEST(span, Contains) EXPECT_FALSE(a_span.contains(8)); } +TEST(mutable_span, Contains) +{ + Vector a = {4, 5, 6, 7}; + MutableSpan a_span = a; + EXPECT_TRUE(a_span.contains(4)); + EXPECT_TRUE(a_span.contains(5)); + EXPECT_TRUE(a_span.contains(6)); + EXPECT_TRUE(a_span.contains(7)); + EXPECT_FALSE(a_span.contains(3)); + EXPECT_FALSE(a_span.contains(8)); +} + TEST(span, Count) { Vector a = {2, 3, 4, 3, 3, 2, 2, 2, 2}; diff --git a/source/blender/editors/curves/intern/curves_ops.cc b/source/blender/editors/curves/intern/curves_ops.cc index bb711b5439d..70eb12cb36a 100644 --- a/source/blender/editors/curves/intern/curves_ops.cc +++ b/source/blender/editors/curves/intern/curves_ops.cc @@ -1364,7 +1364,7 @@ static int exec(bContext *C, wmOperator * /*op*/) [&](const int i) { cyclic.span[i] = !cyclic.span[i]; }); cyclic.finish(); - if (!cyclic.span.as_span().contains(true)) { + if (!cyclic.span.contains(true)) { attributes.remove("cyclic"); }