dtoolbase: fix repeated calls to TypeRegistry::ptr() in register_type

This commit is contained in:
rdb 2019-09-16 21:08:51 +02:00
parent 7fa373bd6a
commit 343c808fc4

View File

@ -25,37 +25,41 @@ register_type(TypeHandle &type_handle, const std::string &name) {
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1) { TypeHandle parent1) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
registry->record_derivation(type_handle, parent1);
} }
} }
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1, TypeHandle parent2) { TypeHandle parent1, TypeHandle parent2) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent1);
registry->record_derivation(type_handle, parent2);
} }
} }
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3) { TypeHandle parent3) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent2);
registry->record_derivation(type_handle, parent3);
} }
} }
INLINE void INLINE void
register_type(TypeHandle &type_handle, const std::string &name, register_type(TypeHandle &type_handle, const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3, TypeHandle parent4) { TypeHandle parent3, TypeHandle parent4) {
if (TypeRegistry::ptr()->register_type(type_handle, name)) { TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->record_derivation(type_handle, parent1); if (registry->register_type(type_handle, name)) {
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent2);
TypeRegistry::ptr()->record_derivation(type_handle, parent4); 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 INLINE TypeHandle
register_dynamic_type(const std::string &name, TypeHandle parent1) { register_dynamic_type(const std::string &name, TypeHandle parent1) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
return type_handle; return type_handle;
} }
INLINE TypeHandle INLINE TypeHandle
register_dynamic_type(const std::string &name, register_dynamic_type(const std::string &name,
TypeHandle parent1, TypeHandle parent2) { TypeHandle parent1, TypeHandle parent2) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent2);
return type_handle; return type_handle;
} }
INLINE TypeHandle INLINE TypeHandle
register_dynamic_type(const std::string &name, register_dynamic_type(const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3) { TypeHandle parent3) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent2);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent3);
return type_handle; return type_handle;
} }
INLINE TypeHandle INLINE TypeHandle
register_dynamic_type(const std::string &name, register_dynamic_type(const std::string &name,
TypeHandle parent1, TypeHandle parent2, TypeHandle parent1, TypeHandle parent2,
TypeHandle parent3, TypeHandle parent4) { TypeHandle parent3, TypeHandle parent4) {
TypeHandle type_handle = TypeRegistry *registry = TypeRegistry::ptr();
TypeRegistry::ptr()->register_dynamic_type(name); TypeHandle type_handle = registry->register_dynamic_type(name);
TypeRegistry::ptr()->record_derivation(type_handle, parent1); registry->record_derivation(type_handle, parent1);
TypeRegistry::ptr()->record_derivation(type_handle, parent2); registry->record_derivation(type_handle, parent2);
TypeRegistry::ptr()->record_derivation(type_handle, parent3); registry->record_derivation(type_handle, parent3);
TypeRegistry::ptr()->record_derivation(type_handle, parent4); registry->record_derivation(type_handle, parent4);
return type_handle; return type_handle;
} }