Cleanup: Use blender::MultiValueMap.
Fixed concern raise on {93e2491ee724}.
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
* and their order is maintained.
|
||||
*
|
||||
* This data structure is different from a `std::multi_map`, because multi_map can store the same
|
||||
* key more than once and MultiValueMap can't.
|
||||
* key more than once and MultiValueMap can't.
|
||||
*
|
||||
* Currently, this class exists mainly for convenience. There are no performance benefits over
|
||||
* using Map<Key, Vector<Value>>. In the future, a better implementation for this data structure
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
* Copyright 2013, Blender Foundation.
|
||||
*/
|
||||
|
||||
#include "BLI_multi_value_map.hh"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "COM_Converter.h"
|
||||
@@ -67,9 +68,9 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
* Inverting yields a map of node inputs to all connected operation inputs,
|
||||
* so multiple operations can use the same node input.
|
||||
*/
|
||||
blender::Map<NodeInput *, blender::Vector<NodeOperationInput *>> inverse_input_map;
|
||||
blender::MultiValueMap<NodeInput *, NodeOperationInput *> inverse_input_map;
|
||||
for (blender::Map<NodeOperationInput *, NodeInput *>::MutableItem item : m_input_map.items()) {
|
||||
inverse_input_map.lookup_or_add_default(item.value).append(item.key);
|
||||
inverse_input_map.add(item.value, item.key);
|
||||
}
|
||||
|
||||
for (const NodeGraph::Link &link : m_graph.links()) {
|
||||
@@ -78,8 +79,8 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
|
||||
NodeOperationOutput *op_from = m_output_map.lookup(from);
|
||||
|
||||
const blender::Vector<NodeOperationInput *> *op_to_list = inverse_input_map.lookup_ptr(to);
|
||||
if (!op_from || op_to_list == nullptr || op_to_list->is_empty()) {
|
||||
const blender::Span<NodeOperationInput *> op_to_list = inverse_input_map.lookup(to);
|
||||
if (!op_from || op_to_list.is_empty()) {
|
||||
/* XXX allow this? error/debug message? */
|
||||
// BLI_assert(false);
|
||||
/* XXX note: this can happen with certain nodes (e.g. OutputFile)
|
||||
@@ -89,7 +90,7 @@ void NodeOperationBuilder::convertToOperations(ExecutionSystem *system)
|
||||
continue;
|
||||
}
|
||||
|
||||
for (NodeOperationInput *op_to : *op_to_list) {
|
||||
for (NodeOperationInput *op_to : op_to_list) {
|
||||
addLink(op_from, op_to);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user