Skip to content

Commit dcf45d7

Browse files
committed
NodeBinding, PlugBinding : Remove isInstanceOf() hacks
These optimisations are now provided universally by Cortex, in ImageEngine/cortex#1535. We have test coverage verifying this is the case already in `BoxTest.testComputeNodeCastDoesntRequirePython`.
1 parent a082180 commit dcf45d7

2 files changed

Lines changed: 0 additions & 62 deletions

File tree

include/GafferBindings/NodeBinding.h

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,47 +77,6 @@ class NodeWrapper : public GraphComponentWrapper<T>
7777
{
7878
}
7979

80-
bool isInstanceOf( IECore::TypeId typeId ) const override
81-
{
82-
// Optimise for common queries for types we know about. The standard
83-
// wrapper implementation of `isInstanceOf()` would have to enter
84-
// Python just in case the type was implemented there. Entering
85-
// Python is incredibly costly for such a simple operation, and we
86-
// perform these operations often, so these optimisations are well
87-
// worth it.
88-
89-
if(
90-
// We're a Node, so we cannot be a plug.
91-
typeId == (IECore::TypeId)Gaffer::PlugTypeId ||
92-
typeId == (IECore::TypeId)Gaffer::ValuePlugTypeId
93-
)
94-
{
95-
return false;
96-
}
97-
98-
if(
99-
// It's important to optimise for ContextProcessor and
100-
// Switch specifically, because they are queried heavily during
101-
// the `Dispatcher::dispatch()` process.
102-
typeId == (IECore::TypeId)Gaffer::ContextProcessorTypeId ||
103-
typeId == (IECore::TypeId)Gaffer::SwitchTypeId ||
104-
// ScriptNode, DependencyNode, ComputeNode and EditScope also
105-
// appear on performance critical code paths.
106-
typeId == (IECore::TypeId)Gaffer::ScriptNodeTypeId ||
107-
typeId == (IECore::TypeId)Gaffer::ComputeNodeTypeId ||
108-
typeId == (IECore::TypeId)Gaffer::DependencyNodeTypeId ||
109-
typeId == (IECore::TypeId)Gaffer::EditScopeTypeId
110-
)
111-
{
112-
// The types above are implemented in C++, so there is no need
113-
// to consider Python overrides for `isInstanceOf()`. The base
114-
// class implementation is sufficient.
115-
return WrappedType::isInstanceOf( typeId );
116-
}
117-
118-
return GraphComponentWrapper<T>::isInstanceOf( typeId );
119-
}
120-
12180
bool acceptsInput( const Gaffer::Plug *plug, const Gaffer::Plug *inputPlug ) const override
12281
{
12382
if( this->isSubclassed() )

include/GafferBindings/PlugBinding.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -69,27 +69,6 @@ class PlugWrapper : public GraphComponentWrapper<WrappedType>
6969
{
7070
}
7171

72-
bool isInstanceOf( IECore::TypeId typeId ) const override
73-
{
74-
// Optimise for common queries we know should fail.
75-
// The standard wrapper implementation of isInstanceOf()
76-
// would have to enter Python only to discover this inevitable
77-
// failure as it doesn't have knowledge of the relationships
78-
// among types. Entering Python is incredibly costly for such
79-
// a simple operation, and we perform these operations often,
80-
// so this optimisation is well worth it.
81-
if(
82-
typeId == (IECore::TypeId)Gaffer::ScriptNodeTypeId ||
83-
typeId == (IECore::TypeId)Gaffer::NodeTypeId ||
84-
typeId == (IECore::TypeId)Gaffer::DependencyNodeTypeId ||
85-
typeId == (IECore::TypeId)Gaffer::ComputeNodeTypeId
86-
)
87-
{
88-
return false;
89-
}
90-
return GraphComponentWrapper<WrappedType>::isInstanceOf( typeId );
91-
}
92-
9372
bool acceptsInput( const Gaffer::Plug *input ) const override
9473
{
9574
if( this->isSubclassed() )

0 commit comments

Comments
 (0)