From 343c808fc486063bae05a82b173d915eeb854c58 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 16 Sep 2019 21:08:51 +0200 Subject: [PATCH] dtoolbase: fix repeated calls to TypeRegistry::ptr() in register_type --- dtool/src/dtoolbase/register_type.I | 68 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/dtool/src/dtoolbase/register_type.I b/dtool/src/dtoolbase/register_type.I index 0bd43e1501..f1108fc0ca 100644 --- a/dtool/src/dtoolbase/register_type.I +++ b/dtool/src/dtoolbase/register_type.I @@ -25,37 +25,41 @@ register_type(TypeHandle &type_handle, const std::string &name) { INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); } } INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); } } INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); } } INLINE void register_type(TypeHandle &type_handle, const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4) { - if (TypeRegistry::ptr()->register_type(type_handle, name)) { - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); - TypeRegistry::ptr()->record_derivation(type_handle, parent4); + TypeRegistry *registry = TypeRegistry::ptr(); + if (registry->register_type(type_handle, name)) { + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); + registry->record_derivation(type_handle, parent4); } } @@ -71,40 +75,40 @@ register_dynamic_type(const std::string &name) { } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); return type_handle; } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); return type_handle; } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); return type_handle; } INLINE TypeHandle register_dynamic_type(const std::string &name, TypeHandle parent1, TypeHandle parent2, TypeHandle parent3, TypeHandle parent4) { - TypeHandle type_handle = - TypeRegistry::ptr()->register_dynamic_type(name); - TypeRegistry::ptr()->record_derivation(type_handle, parent1); - TypeRegistry::ptr()->record_derivation(type_handle, parent2); - TypeRegistry::ptr()->record_derivation(type_handle, parent3); - TypeRegistry::ptr()->record_derivation(type_handle, parent4); + TypeRegistry *registry = TypeRegistry::ptr(); + TypeHandle type_handle = registry->register_dynamic_type(name); + registry->record_derivation(type_handle, parent1); + registry->record_derivation(type_handle, parent2); + registry->record_derivation(type_handle, parent3); + registry->record_derivation(type_handle, parent4); return type_handle; }