Made string passing in World a little more effective

This commit is contained in:
2016-01-14 15:42:55 +01:00
parent 71d936f8d1
commit 28392def79
2 changed files with 10 additions and 10 deletions
+5 -5
View File
@@ -66,7 +66,7 @@ void World::RegisterComponent(ComponentInfo& ci)
}
}
ComponentWrapper World::AttachComponent(EntityID entity, std::string componentType)
ComponentWrapper World::AttachComponent(EntityID entity, const std::string& componentType)
{
// TODO: Allocate dynamic pool if component isn't registered
ComponentPool* pool = m_ComponentPools.at(componentType);
@@ -80,26 +80,26 @@ ComponentWrapper World::AttachComponent(EntityID entity, std::string componentTy
return c;
}
bool World::HasComponent(EntityID entity, std::string componentType) const
bool World::HasComponent(EntityID entity, const std::string& componentType) const
{
ComponentPool* pool = m_ComponentPools.at(componentType);
return pool->KnowsEntity(entity);
}
ComponentWrapper World::GetComponent(EntityID entity, std::string componentType)
ComponentWrapper World::GetComponent(EntityID entity, const std::string& componentType)
{
ComponentPool* pool = m_ComponentPools.at(componentType);
return pool->GetByEntity(entity);
}
void World::DeleteComponent(EntityID entity, std::string componentType)
void World::DeleteComponent(EntityID entity, const std::string& componentType)
{
ComponentPool* pool = m_ComponentPools.at(componentType);
ComponentWrapper c = pool->GetByEntity(entity);
return pool->Delete(c);
}
const ComponentPool* World::GetComponents(std::string componentType)
const ComponentPool* World::GetComponents(const std::string& componentType)
{
auto it = m_ComponentPools.find(componentType);
return (it != m_ComponentPools.end()) ? it->second : nullptr;