[Bf-blender-cvs] [9c0cd8d7a3b] functions: cleanup
Jacques Lucke
noreply at git.blender.org
Mon Jan 27 22:10:45 CET 2020
Commit: 9c0cd8d7a3b9200feb1088bb870ce9ebb85b2835
Author: Jacques Lucke
Date: Mon Jan 27 16:36:26 2020 +0100
Branches: functions
https://developer.blender.org/rB9c0cd8d7a3b9200feb1088bb870ce9ebb85b2835
cleanup
===================================================================
M source/blender/blenkernel/intern/virtual_node_tree.cc
M source/blender/blenlib/BLI_monotonic_allocator.h
M source/blender/blenlib/BLI_resource_collector.h
M source/blender/functions/intern/multi_function_network.cc
M source/blender/functions/intern/multi_functions/network.cc
M source/blender/functions/intern/node_tree.cc
===================================================================
diff --git a/source/blender/blenkernel/intern/virtual_node_tree.cc b/source/blender/blenkernel/intern/virtual_node_tree.cc
index 03a1780d599..7fb60c8510e 100644
--- a/source/blender/blenkernel/intern/virtual_node_tree.cc
+++ b/source/blender/blenkernel/intern/virtual_node_tree.cc
@@ -24,7 +24,7 @@ VirtualNodeTree::VirtualNodeTree(bNodeTree *btree) : m_btree(btree)
Map<bNode *, VNode *> node_mapping;
for (bNode *bnode : BNodeList(btree->nodes)) {
- VNode &vnode = *vtree.m_allocator.construct<VNode>().release();
+ VNode &vnode = *vtree.m_allocator.construct<VNode>();
vnode.m_vtree = &vtree;
vnode.m_bnode = bnode;
@@ -32,7 +32,7 @@ VirtualNodeTree::VirtualNodeTree(bNodeTree *btree) : m_btree(btree)
RNA_pointer_create(&btree->id, &RNA_Node, bnode, &vnode.m_rna);
for (bNodeSocket *bsocket : BSocketList(bnode->inputs)) {
- VInputSocket &vsocket = *vtree.m_allocator.construct<VInputSocket>().release();
+ VInputSocket &vsocket = *vtree.m_allocator.construct<VInputSocket>();
vsocket.m_node = &vnode;
vsocket.m_index = vnode.m_inputs.append_and_get_index(&vsocket);
@@ -45,7 +45,7 @@ VirtualNodeTree::VirtualNodeTree(bNodeTree *btree) : m_btree(btree)
}
for (bNodeSocket *bsocket : BSocketList(bnode->outputs)) {
- VOutputSocket &vsocket = *vtree.m_allocator.construct<VOutputSocket>().release();
+ VOutputSocket &vsocket = *vtree.m_allocator.construct<VOutputSocket>();
vsocket.m_node = &vnode;
vsocket.m_index = vnode.m_outputs.append_and_get_index(&vsocket);
diff --git a/source/blender/blenlib/BLI_monotonic_allocator.h b/source/blender/blenlib/BLI_monotonic_allocator.h
index 552e27b7b63..838342678ec 100644
--- a/source/blender/blenlib/BLI_monotonic_allocator.h
+++ b/source/blender/blenlib/BLI_monotonic_allocator.h
@@ -104,11 +104,11 @@ class MonotonicAllocator : NonCopyable, NonMovable {
return StringRefNull((const char *)buffer);
}
- template<typename T, typename... Args> destruct_ptr<T> construct(Args &&... args)
+ template<typename T, typename... Args> T *construct(Args &&... args)
{
void *buffer = this->allocate(sizeof(T), alignof(T));
T *value = new (buffer) T(std::forward<Args>(args)...);
- return destruct_ptr<T>(value);
+ return value;
}
template<typename T, typename... Args>
diff --git a/source/blender/blenlib/BLI_resource_collector.h b/source/blender/blenlib/BLI_resource_collector.h
index 9de0a553869..b2e3bd3d225 100644
--- a/source/blender/blenlib/BLI_resource_collector.h
+++ b/source/blender/blenlib/BLI_resource_collector.h
@@ -71,10 +71,9 @@ class ResourceCollector : NonCopyable {
template<typename T, typename... Args> T &construct(const char *name, Args &&... args)
{
- destruct_ptr<T> value = m_allocator.construct<T>(std::forward<Args>(args)...);
- T &value_ref = *value;
- this->add(std::move(value), name);
- return value_ref;
+ T *value = m_allocator.construct<T>(std::forward<Args>(args)...);
+ this->add(destruct_ptr<T>(value), name);
+ return *value;
}
void add(void *userdata, void (*free)(void *), const char *name)
diff --git a/source/blender/functions/intern/multi_function_network.cc b/source/blender/functions/intern/multi_function_network.cc
index ef089f451f4..ce970ec9f99 100644
--- a/source/blender/functions/intern/multi_function_network.cc
+++ b/source/blender/functions/intern/multi_function_network.cc
@@ -65,7 +65,7 @@ MFBuilderFunctionNode &MFNetworkBuilder::add_function(const MultiFunction &funct
}
}
- auto &node = *m_allocator.construct<MFBuilderFunctionNode>().release();
+ auto &node = *m_allocator.construct<MFBuilderFunctionNode>();
m_function_nodes.add_new(&node);
node.m_network = this;
@@ -116,7 +116,7 @@ MFBuilderDummyNode &MFNetworkBuilder::add_dummy(StringRef name,
BLI_assert(input_types.size() == input_names.size());
BLI_assert(output_types.size() == output_names.size());
- auto &node = *m_allocator.construct<MFBuilderDummyNode>().release();
+ auto &node = *m_allocator.construct<MFBuilderDummyNode>();
m_dummy_nodes.add_new(&node);
node.m_network = this;
@@ -371,7 +371,7 @@ MFNetwork::MFNetwork(MFNetworkBuilder &builder)
uint input_amount = builder_node->inputs().size();
uint output_amount = builder_node->outputs().size();
- MFFunctionNode &node = *m_allocator.construct<MFFunctionNode>().release();
+ MFFunctionNode &node = *m_allocator.construct<MFFunctionNode>();
node.m_function = &builder_node->function();
node.m_id = m_node_by_id.append_and_get_index(&node);
@@ -417,7 +417,7 @@ MFNetwork::MFNetwork(MFNetworkBuilder &builder)
uint input_amount = builder_node->inputs().size();
uint output_amount = builder_node->outputs().size();
- MFDummyNode &node = *m_allocator.construct<MFDummyNode>().release();
+ MFDummyNode &node = *m_allocator.construct<MFDummyNode>();
node.m_id = m_node_by_id.append_and_get_index(&node);
node.m_network = this;
diff --git a/source/blender/functions/intern/multi_functions/network.cc b/source/blender/functions/intern/multi_functions/network.cc
index 132e7302cbe..ea196217643 100644
--- a/source/blender/functions/intern/multi_functions/network.cc
+++ b/source/blender/functions/intern/multi_functions/network.cc
@@ -193,7 +193,7 @@ class NetworkEvaluationStorage {
BLI_assert(m_value_per_output_id[socket.id()] == nullptr);
BLI_assert(list_ref.size() >= m_min_array_size);
- auto *value = m_allocator.construct<SingleFromCallerValue>(list_ref).release();
+ auto *value = m_allocator.construct<SingleFromCallerValue>(list_ref);
m_value_per_output_id[socket.id()] = value;
}
@@ -203,7 +203,7 @@ class NetworkEvaluationStorage {
BLI_assert(m_value_per_output_id[socket.id()] == nullptr);
BLI_assert(list_list_ref.size() >= m_min_array_size);
- auto *value = m_allocator.construct<VectorFromCallerValue>(list_list_ref).release();
+ auto *value = m_allocator.construct<VectorFromCallerValue>(list_list_ref);
m_value_per_output_id[socket.id()] = value;
}
@@ -218,8 +218,7 @@ class NetworkEvaluationStorage {
void *buffer = m_array_allocator.allocate(type.size(), type.alignment());
GenericMutableArrayRef array_ref(type, buffer, m_min_array_size);
- auto *value =
- m_allocator.construct<SingleValue>(array_ref, socket.target_amount(), false).release();
+ auto *value = m_allocator.construct<SingleValue>(array_ref, socket.target_amount(), false);
m_value_per_output_id[socket.id()] = value;
return array_ref;
@@ -233,8 +232,7 @@ class NetworkEvaluationStorage {
void *buffer = m_allocator.allocate(type.size(), type.alignment());
GenericMutableArrayRef array_ref(type, buffer, 1);
- auto *value =
- m_allocator.construct<SingleValue>(array_ref, socket.target_amount(), true).release();
+ auto *value = m_allocator.construct<SingleValue>(array_ref, socket.target_amount(), true);
m_value_per_output_id[socket.id()] = value;
return value->array_ref;
@@ -247,8 +245,7 @@ class NetworkEvaluationStorage {
const CPPType &type = socket.data_type().vector__cpp_base_type();
GenericVectorArray *vector_array = new GenericVectorArray(type, m_min_array_size);
- auto *value =
- m_allocator.construct<VectorValue>(*vector_array, socket.target_amount()).release();
+ auto *value = m_allocator.construct<VectorValue>(*vector_array, socket.target_amount());
m_value_per_output_id[socket.id()] = value;
return *value->vector_array;
@@ -261,8 +258,7 @@ class NetworkEvaluationStorage {
const CPPType &type = socket.data_type().vector__cpp_base_type();
GenericVectorArray *vector_array = new GenericVectorArray(type, 1);
- auto *value =
- m_allocator.construct<VectorValue>(*vector_array, socket.target_amount()).release();
+ auto *value = m_allocator.construct<VectorValue>(*vector_array, socket.target_amount());
m_value_per_output_id[socket.id()] = value;
return *value->vector_array;
@@ -297,8 +293,8 @@ class NetworkEvaluationStorage {
GenericMutableArrayRef new_array_ref(type, new_buffer, m_min_array_size);
list_ref.materialize_to_uninitialized(m_mask, new_array_ref);
- SingleValue *new_value =
- m_allocator.construct<SingleValue>(new_array_ref, to.target_amount(), false).release();
+ SingleValue *new_value = m_allocator.construct<SingleValue>(
+ new_array_ref, to.target_amount(), false);
m_value_per_output_id[to.id()] = new_value;
return new_array_ref;
}
@@ -331,8 +327,8 @@ class NetworkEvaluationStorage {
type.copy_to_uninitialized(list_ref.as_single_element(), new_buffer);
GenericMutableArrayRef new_array_ref(type, new_buffer, 1);
- SingleValue *new_value =
- m_allocator.construct<SingleValue>(new_array_ref, to.target_amount(), true).release();
+ SingleValue *new_value = m_allocator.construct<SingleValue>(
+ new_array_ref, to.target_amount(), true);
m_value_per_output_id[to.id()] = new_value;
return new_array_ref;
}
@@ -363,8 +359,8 @@ class NetworkEvaluationStorage {
GenericVectorArray *new_vector_array = new GenericVectorArray(base_type, m_min_array_size);
new_vector_array->extend_multiple__copy(m_mask, list_list_ref);
- VectorValue *new_value =
- m_allocator.construct<VectorValue>(*new_vector_array, to.target_amount()).release();
+ VectorValue *new_value = m_allocator.construct<VectorValue>(*new_vector_array,
+ to.target_amount());
m_value_per_output_id[to.id()] = new_value;
return *new_vector_array;
@@ -396,8 +392,8 @@ class NetworkEvaluationStorage {
GenericVectorArray *new_vector_array = new GenericVectorArray(base_type, 1);
new_vector_array->extend_single__copy(0, list_list_ref[0]);
- VectorValue *new_value =
- m_allocator.construct<VectorValue>(*new_vector_array, to.target_amount()).release();
+ VectorValue *new_value = m_allocator.construct<VectorValue>(*new_vector_array,
+ to.target_amount());
m_value_per_output_id[to
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list