diff --git a/src/RageTextureManager.cpp b/src/RageTextureManager.cpp index 8d62c7edeb..df0f723677 100644 --- a/src/RageTextureManager.cpp +++ b/src/RageTextureManager.cpp @@ -36,7 +36,7 @@ #include RageTextureManager* TEXTUREMAN = - NULL; // global and accessible from anywhere in our program + nullptr; // global and accessible from anywhere in our program namespace { map m_mapPathToTexture; @@ -74,9 +74,8 @@ RageTextureManager::Update(float fDeltaTime) } } - FOREACHM(RageTextureID, RageTexture*, m_textures_to_update, i) - { - RageTexture* pTexture = i->second; + for (auto& id : m_textures_to_update) { + RageTexture* pTexture = id.second; pTexture->Update(fDeltaTime); } } @@ -108,9 +107,7 @@ RageTextureManager::RegisterTexture(RageTextureID ID, RageTexture* pTexture) /* Make sure we don't already have a texture with this ID. If we do, the * caller should have used it. */ - std::map::iterator p = - m_mapPathToTexture.find(ID); - if (p != m_mapPathToTexture.end()) { + if (m_mapPathToTexture.count(ID) == 1) { /* Oops, found the texture. */ RageException::Throw("Custom texture \"%s\" already registered!", ID.filename.c_str()); @@ -234,7 +231,7 @@ RageTextureManager::VolatileTexture(const RageTextureID& ID) void RageTextureManager::UnloadTexture(RageTexture* t) { - if (t == NULL) + if (t == nullptr) return; t->m_iRefCount--; @@ -314,14 +311,8 @@ RageTextureManager::GarbageCollect(GCType type) if (PREFSMAN->m_verbose_log > 1) LOG->Trace("Performing texture garbage collection."); - for (std::map::iterator i = - m_mapPathToTexture.begin(); - i != m_mapPathToTexture.end();) { - std::map::iterator j = i; - i++; - - RString sPath = j->first.filename; - RageTexture* t = j->second; + for (auto ID : m_mapPathToTexture) { + RageTexture* t = ID.second; if (t->m_iRefCount) continue; /* Can't unload textures that are still referenced. */ @@ -368,9 +359,8 @@ RageTextureManager::ReloadAll() * ton of cached data that we're not necessarily going to use. */ DoDelayedDelete(); - FOREACHM(RageTextureID, RageTexture*, m_mapPathToTexture, i) - { - i->second->Reload(); + for (auto ID : m_mapPathToTexture) { + ID.second->Reload(); } EnableOddDimensionWarning(); diff --git a/src/RageTextureManager.h b/src/RageTextureManager.h index 9afcf21af8..a34e057233 100644 --- a/src/RageTextureManager.h +++ b/src/RageTextureManager.h @@ -1,4 +1,4 @@ -/* RageTextureManager - Interface for loading textures. */ +/* RageTextureManager - Interface for loading textures. */ #ifndef RAGE_TEXTURE_MANAGER_H #define RAGE_TEXTURE_MANAGER_H