diff options
author | Jeroen Bakker <jeroen@blender.org> | 2021-03-17 11:14:38 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-03-17 11:14:38 +0300 |
commit | 187f358f33e5b409ef12a5bce92a76edc3a77725 (patch) | |
tree | 0c0f8391d4e349f47cd51aa37ed09559bbe30efd /source | |
parent | 97defd9cd79b6e3ed0e52481a7078107dbe0522b (diff) |
Cleanup: Use blender::MultiValueMap.
Fixed concern raise on {93e2491ee724}.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/BLI_multi_value_map.hh | 2 | ||||
-rw-r--r-- | source/blender/compositor/intern/COM_NodeOperationBuilder.cc | 11 |
2 files changed, 7 insertions, 6 deletions
diff --git a/source/blender/blenlib/BLI_multi_value_map.hh b/source/blender/blenlib/BLI_multi_value_map.hh index 4113085a1e3..5652e8f1bba 100644 --- a/source/blender/blenlib/BLI_multi_value_map.hh +++ b/source/blender/blenlib/BLI_multi_value_map.hh @@ -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 diff --git a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc index aac1d1d747c..306ca1bd8dd 100644 --- a/source/blender/compositor/intern/COM_NodeOperationBuilder.cc +++ b/source/blender/compositor/intern/COM_NodeOperationBuilder.cc @@ -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); } } |