diff options
author | Jacques Lucke <jacques@blender.org> | 2021-06-11 17:21:08 +0300 |
---|---|---|
committer | Jacques Lucke <jacques@blender.org> | 2021-06-11 17:21:23 +0300 |
commit | 605ce623be70b089a7059b03f2eb6852902136da (patch) | |
tree | 7b2fc421cbc2ac558741b8d7775bf70247b22f45 /source/blender/nodes/NOD_derived_node_tree.hh | |
parent | 7b30a3e98def6f9f158da0e315b7077655acfd20 (diff) |
Nodes: cache socket identifier to index mapping
While this preprocessing does take some time upfront,
it avoids longer lookup later on, especially as nodes get
more sockets.
It's probably possible to make this more efficient in some cases
but this is good enough for now.
Diffstat (limited to 'source/blender/nodes/NOD_derived_node_tree.hh')
-rw-r--r-- | source/blender/nodes/NOD_derived_node_tree.hh | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/source/blender/nodes/NOD_derived_node_tree.hh b/source/blender/nodes/NOD_derived_node_tree.hh index e12e0bde975..de9e4c8c812 100644 --- a/source/blender/nodes/NOD_derived_node_tree.hh +++ b/source/blender/nodes/NOD_derived_node_tree.hh @@ -95,6 +95,9 @@ class DNode { DInputSocket input(int index) const; DOutputSocket output(int index) const; + + DInputSocket input_by_identifier(StringRef identifier) const; + DOutputSocket output_by_identifier(StringRef identifier) const; }; /* A (nullable) reference to a socket and the context it is in. It is unique within an entire @@ -288,6 +291,16 @@ inline DOutputSocket DNode::output(int index) const return {context_, &node_ref_->output(index)}; } +inline DInputSocket DNode::input_by_identifier(StringRef identifier) const +{ + return {context_, &node_ref_->input_by_identifier(identifier)}; +} + +inline DOutputSocket DNode::output_by_identifier(StringRef identifier) const +{ + return {context_, &node_ref_->output_by_identifier(identifier)}; +} + /* -------------------------------------------------------------------- * DSocket inline methods. */ |