1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2024-12-29 03:19:44 +00:00

Sprinkle some const-ref in loop

This was done on the good advices of clang-tidy
This commit is contained in:
jvoisin 2021-08-29 15:15:45 +02:00
parent 76320aae45
commit cb08f490d7
3 changed files with 13 additions and 14 deletions

View File

@ -30,7 +30,7 @@ namespace Resource
std::vector<SceneUtil::EmulatedAnimation> emulatedAnimations;
for (auto animation : mAnimationManager->getAnimationList())
for (const auto& animation : mAnimationManager->getAnimationList())
{
if (animation)
{

View File

@ -371,11 +371,10 @@ namespace Shader
void ShaderManager::setGlobalDefines(DefineMap & globalDefines)
{
mGlobalDefines = globalDefines;
for (auto shaderMapElement: mShaders)
for (const auto& [key, shader]: mShaders)
{
std::string templateId = shaderMapElement.first.first;
ShaderManager::DefineMap defines = shaderMapElement.first.second;
osg::ref_ptr<osg::Shader> shader = shaderMapElement.second;
std::string templateId = key.first;
ShaderManager::DefineMap defines = key.second;
if (shader == nullptr)
// I'm not sure how to handle a shader that was already broken as there's no way to get a potential replacement to the nodes that need it.
continue;
@ -391,13 +390,13 @@ namespace Shader
void ShaderManager::releaseGLObjects(osg::State *state)
{
std::lock_guard<std::mutex> lock(mMutex);
for (auto shader : mShaders)
for (const auto& [_, shader] : mShaders)
{
if (shader.second != nullptr)
shader.second->releaseGLObjects(state);
if (shader != nullptr)
shader->releaseGLObjects(state);
}
for (auto program : mPrograms)
program.second->releaseGLObjects(state);
for (const auto& [_, program] : mPrograms)
program->releaseGLObjects(state);
}
}

View File

@ -245,13 +245,13 @@ namespace Terrain
{
{
std::lock_guard<std::mutex> lock(mIndexBufferMutex);
for (auto indexbuffer : mIndexBufferMap)
indexbuffer.second->releaseGLObjects(state);
for (const auto& [_, indexbuffer] : mIndexBufferMap)
indexbuffer->releaseGLObjects(state);
}
{
std::lock_guard<std::mutex> lock(mUvBufferMutex);
for (auto uvbuffer : mUvBufferMap)
uvbuffer.second->releaseGLObjects(state);
for (const auto& [_, uvbuffer] : mUvBufferMap)
uvbuffer->releaseGLObjects(state);
}
}