Base: Use pass by value instead of reference as size is small

This commit is contained in:
Benjamin Nauck
2025-02-13 20:26:50 +01:00
parent 15c8ab5b4f
commit e7ea25bea2
2 changed files with 10 additions and 13 deletions

View File

@@ -129,7 +129,7 @@ std::string Type::getModuleName(const char* ClassName)
}
Type Type::createType(const Type& parent, const char* name, instantiationMethod method)
Type Type::createType(const Type parent, const char* name, instantiationMethod method)
{
Type newType;
newType.index = static_cast<unsigned int>(Type::typedata.size());
@@ -193,9 +193,8 @@ Type Type::getParent() const
return typedata[index]->parent;
}
bool Type::isDerivedFrom(const Type& type) const
bool Type::isDerivedFrom(const Type type) const
{
Type temp(*this);
do {
if (temp == type) {
@@ -207,7 +206,7 @@ bool Type::isDerivedFrom(const Type& type) const
return false;
}
int Type::getAllDerivedFrom(const Type& type, std::vector<Type>& List)
int Type::getAllDerivedFrom(const Type type, std::vector<Type>& List)
{
int cnt = 0;
@@ -225,15 +224,13 @@ int Type::getNumTypes()
return static_cast<int>(typedata.size());
}
Type Type::getTypeIfDerivedFrom(const char* name, const Type& parent, bool bLoadModule)
Type Type::getTypeIfDerivedFrom(const char* name, const Type parent, bool loadModule)
{
if (bLoadModule) {
if (loadModule) {
importModule(name);
}
Type type = fromName(name);
if (type.isDerivedFrom(parent)) {
if (Type type(fromName(name)); type.isDerivedFrom(parent)) {
return type;
}

View File

@@ -101,17 +101,17 @@ public:
static Type fromKey(unsigned int key);
const char* getName() const;
Type getParent() const;
bool isDerivedFrom(const Type& type) const;
bool isDerivedFrom(const Type type) const;
static int getAllDerivedFrom(const Type& type, std::vector<Type>& List);
static int getAllDerivedFrom(const Type type, std::vector<Type>& List);
/// Returns the given named type if is derived from parent type, otherwise return bad type
static Type
getTypeIfDerivedFrom(const char* name, const Type& parent, bool bLoadModule = false);
getTypeIfDerivedFrom(const char* name, const Type parent, bool loadModule = false);
static int getNumTypes();
static Type
createType(const Type& parent, const char* name, instantiationMethod method = nullptr);
createType(const Type parent, const char* name, instantiationMethod method = nullptr);
unsigned int getKey() const;
bool isBad() const;