[Bf-blender-cvs] [187f358f33e] master: Cleanup: Use blender::MultiValueMap.
Jeroen Bakker
noreply at git.blender.org
Wed Mar 17 09:19:43 CET 2021
Commit: 187f358f33e5b409ef12a5bce92a76edc3a77725
Author: Jeroen Bakker
Date: Wed Mar 17 09:14:38 2021 +0100
Branches: master
https://developer.blender.org/rB187f358f33e5b409ef12a5bce92a76edc3a77725
Cleanup: Use blender::MultiValueMap.
Fixed concern raise on {93e2491ee724}.
===================================================================
M source/blender/blenlib/BLI_multi_value_map.hh
M source/blender/compositor/intern/COM_NodeOperationBuilder.cc
===================================================================
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);
}
}
More information about the Bf-blender-cvs
mailing list