Cleanup: remove unnecessary "for_write" in method name

This suffix is only preferred when the non-const version does more
work than the const version of a method (e.g. because it may duplicate
data because of implicit sharing).
This commit is contained in:
Jacques Lucke 2023-06-21 09:26:18 +02:00
parent 4ed4fa8106
commit ec18e11c37
3 changed files with 13 additions and 4 deletions

View File

@ -746,6 +746,15 @@ template<typename T> class MutableSpan {
return counter;
}
/**
* 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.
*/
constexpr bool contains_ptr(const T *ptr) const
{
return (this->begin() <= ptr) && (ptr < this->end());
}
/**
* Copy all values from another span into this span. This invokes undefined behavior when the
* destination contains uninitialized data and T is not trivially copy constructible.

View File

@ -1661,7 +1661,7 @@ typedef struct NodeGeometrySimulationOutput {
#ifdef __cplusplus
blender::Span<NodeSimulationItem> items_span() const;
blender::MutableSpan<NodeSimulationItem> items_span_for_write();
blender::MutableSpan<NodeSimulationItem> items_span();
blender::IndexRange items_range() const;
#endif
} NodeGeometrySimulationOutput;

View File

@ -995,7 +995,7 @@ blender::Span<NodeSimulationItem> NodeGeometrySimulationOutput::items_span() con
return blender::Span<NodeSimulationItem>(items, items_num);
}
blender::MutableSpan<NodeSimulationItem> NodeGeometrySimulationOutput::items_span_for_write()
blender::MutableSpan<NodeSimulationItem> NodeGeometrySimulationOutput::items_span()
{
return blender::MutableSpan<NodeSimulationItem>(items, items_num);
}
@ -1077,7 +1077,7 @@ void NOD_geometry_simulation_output_set_active_item(NodeGeometrySimulationOutput
NodeSimulationItem *NOD_geometry_simulation_output_find_item(NodeGeometrySimulationOutput *sim,
const char *name)
{
for (NodeSimulationItem &item : sim->items_span_for_write()) {
for (NodeSimulationItem &item : sim->items_span()) {
if (STREQ(item.name, name)) {
return &item;
}
@ -1164,7 +1164,7 @@ void NOD_geometry_simulation_output_remove_item(NodeGeometrySimulationOutput *si
void NOD_geometry_simulation_output_clear_items(NodeGeometrySimulationOutput *sim)
{
for (NodeSimulationItem &item : sim->items_span_for_write()) {
for (NodeSimulationItem &item : sim->items_span()) {
MEM_SAFE_FREE(item.name);
}
MEM_SAFE_FREE(sim->items);