Depsgraph: Use array instead of set for node factory
Avoids extra time spent on hashing and such. Old comment is kind of weird, because types we can totally make a sequent integer values.
This commit is contained in:
parent
4ce38abfcd
commit
3d72b94196
|
@ -51,14 +51,7 @@ namespace DEG {
|
|||
|
||||
/* Global type registry */
|
||||
|
||||
/**
|
||||
* \note For now, this is a hashtable not array, since the core node types
|
||||
* currently do not have contiguous ID values. Using a hash here gives us
|
||||
* more flexibility, albeit using more memory and also sacrificing a little
|
||||
* speed. Later on, when things stabilise we may turn this back to an array
|
||||
* since there are only just a few node types that an array would cope fine...
|
||||
*/
|
||||
static GHash *_depsnode_typeinfo_registry = NULL;
|
||||
static DepsNodeFactory *depsnode_typeinfo_registry[NUM_DEG_NODE_TYPES] = {NULL};
|
||||
|
||||
/* Registration ------------------------------------------- */
|
||||
|
||||
|
@ -66,9 +59,7 @@ static GHash *_depsnode_typeinfo_registry = NULL;
|
|||
void deg_register_node_typeinfo(DepsNodeFactory *factory)
|
||||
{
|
||||
BLI_assert(factory != NULL);
|
||||
BLI_ghash_insert(_depsnode_typeinfo_registry,
|
||||
SET_INT_IN_POINTER(factory->type()),
|
||||
factory);
|
||||
depsnode_typeinfo_registry[factory->type()] = factory;
|
||||
}
|
||||
|
||||
/* Getters ------------------------------------------------- */
|
||||
|
@ -77,8 +68,7 @@ void deg_register_node_typeinfo(DepsNodeFactory *factory)
|
|||
DepsNodeFactory *deg_get_node_factory(const eDepsNode_Type type)
|
||||
{
|
||||
/* look up type - at worst, it doesn't exist in table yet, and we fail */
|
||||
return (DepsNodeFactory *)BLI_ghash_lookup(_depsnode_typeinfo_registry,
|
||||
SET_INT_IN_POINTER(type));
|
||||
return depsnode_typeinfo_registry[type];
|
||||
}
|
||||
|
||||
/* Get typeinfo for provided node */
|
||||
|
@ -169,9 +159,6 @@ const char *DepsOperationStringifier::operator[](eDepsOperation_Code opcode)
|
|||
/* Register all node types */
|
||||
void DEG_register_node_types(void)
|
||||
{
|
||||
/* initialise registry */
|
||||
DEG::_depsnode_typeinfo_registry = BLI_ghash_int_new("Depsgraph Node Type Registry");
|
||||
|
||||
/* register node types */
|
||||
DEG::deg_register_base_depsnodes();
|
||||
DEG::deg_register_component_depsnodes();
|
||||
|
@ -181,5 +168,4 @@ void DEG_register_node_types(void)
|
|||
/* Free registry on exit */
|
||||
void DEG_free_node_types(void)
|
||||
{
|
||||
BLI_ghash_free(DEG::_depsnode_typeinfo_registry, NULL, NULL);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue