From d6cd2e2e7e2317c3a2bf22bc050e588fef741b46 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 26 Aug 2014 00:05:08 -0300 Subject: [PATCH] Prettied up some code. --- src/modules/audio/openal/Pool.cpp | 26 +++++++++++--------------- src/modules/graphics/Volatile.cpp | 17 ++++------------- src/modules/graphics/opengl/OpenGL.cpp | 7 +++---- 3 files changed, 18 insertions(+), 32 deletions(-) diff --git a/src/modules/audio/openal/Pool.cpp b/src/modules/audio/openal/Pool.cpp index 8d239f4d7..3472c249c 100644 --- a/src/modules/audio/openal/Pool.cpp +++ b/src/modules/audio/openal/Pool.cpp @@ -98,11 +98,7 @@ bool Pool::isPlaying(Source *s) bool p = false; { thread::Lock lock(mutex); - for (auto i = playing.begin(); i != playing.end(); i++) - { - if (i->first == s) - p = true; - } + p = (playing.find(s) != playing.end()); } return p; } @@ -181,11 +177,11 @@ bool Pool::play(Source *source, ALuint &out) void Pool::stop() { thread::Lock lock(mutex); - for (auto i = playing.begin(); i != playing.end(); i++) + for (const auto &i : playing) { - i->first->stopAtomic(); - i->first->release(); - available.push(i->second); + i.first->stopAtomic(); + i.first->release(); + available.push(i.second); } playing.clear(); @@ -200,8 +196,8 @@ void Pool::stop(Source *source) void Pool::pause() { thread::Lock lock(mutex); - for (auto i = playing.begin(); i != playing.end(); i++) - i->first->pauseAtomic(); + for (const auto &i : playing) + i.first->pauseAtomic(); } void Pool::pause(Source *source) @@ -215,8 +211,8 @@ void Pool::pause(Source *source) void Pool::resume() { thread::Lock lock(mutex); - for (auto i = playing.begin(); i != playing.end(); i++) - i->first->resumeAtomic(); + for (const auto &i : playing) + i.first->resumeAtomic(); } void Pool::resume(Source *source) @@ -230,8 +226,8 @@ void Pool::resume(Source *source) void Pool::rewind() { thread::Lock lock(mutex); - for (auto i = playing.begin(); i != playing.end(); i++) - i->first->rewindAtomic(); + for (const auto &i : playing) + i.first->rewindAtomic(); } // For those times we don't need it backed. diff --git a/src/modules/graphics/Volatile.cpp b/src/modules/graphics/Volatile.cpp index 920d8668d..d97b1623a 100644 --- a/src/modules/graphics/Volatile.cpp +++ b/src/modules/graphics/Volatile.cpp @@ -43,26 +43,17 @@ Volatile::~Volatile() bool Volatile::loadAll() { bool success = true; - std::list::iterator i = all.begin(); - while (i != all.end()) - { - success = success && (*i)->loadVolatile(); - i++; - } + for (Volatile *v : all) + success = success && v->loadVolatile(); return success; } void Volatile::unloadAll() { - std::list::iterator i = all.begin(); - - while (i != all.end()) - { - (*i)->unloadVolatile(); - i++; - } + for (Volatile *v : all) + v->unloadVolatile(); } } // graphics diff --git a/src/modules/graphics/opengl/OpenGL.cpp b/src/modules/graphics/opengl/OpenGL.cpp index f45bed50d..9be31ae92 100644 --- a/src/modules/graphics/opengl/OpenGL.cpp +++ b/src/modules/graphics/opengl/OpenGL.cpp @@ -521,11 +521,10 @@ void OpenGL::deleteTexture(GLuint texture) { // glDeleteTextures binds texture 0 to all texture units the deleted texture // was bound to before deletion. - std::vector::iterator it; - for (it = state.textureUnits.begin(); it != state.textureUnits.end(); ++it) + for (GLuint &texid : state.textureUnits) { - if (*it == texture) - *it = 0; + if (texid == texture) + texid = 0; } glDeleteTextures(1, &texture);