From 396a2c744058c719e79471d7bc8a43bf9d3ca45f Mon Sep 17 00:00:00 2001 From: jmacey Date: Fri, 29 Sep 2023 13:50:16 +0100 Subject: [PATCH] removed some code smells --- src/Image.cpp | 4 ++-- src/Shader.cpp | 5 ++++- src/Text.cpp | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Image.cpp b/src/Image.cpp index f7e6169c..48d202be 100644 --- a/src/Image.cpp +++ b/src/Image.cpp @@ -373,8 +373,8 @@ bool Image::load(std::string_view _fname,bool _flipY) noexcept int ch; stbi_set_flip_vertically_on_load(_flipY); - unsigned char *img = stbi_load(fname, &w, &h, &ch, 0); - if(img != nullptr) + + if(unsigned char *img = stbi_load(fname, &w, &h, &ch, 0); img != nullptr) { NGLMessage::addMessage(fmt::format("loaded {} Width {} Height {} Channels {}", fname, w, h, ch)); m_width = w; diff --git a/src/Shader.cpp b/src/Shader.cpp index 7de9c7b0..4b91303c 100644 --- a/src/Shader.cpp +++ b/src/Shader.cpp @@ -84,7 +84,10 @@ m_name{_name},m_errorExit(_exitOnError) } #endif break; - case ShaderType::NONE:{} + case ShaderType::NONE: + { + // nothing to do + } } m_compiled = false; m_refCount = 0; diff --git a/src/Text.cpp b/src/Text.cpp index fcff940f..b7d35447 100644 --- a/src/Text.cpp +++ b/src/Text.cpp @@ -99,7 +99,7 @@ Text::Text(std::string_view _name, int _size) Text::~Text() { // our dtor should clear out the textures and remove the VAO's - for(auto [c,font] : m_characters) + for(auto &[c,font] : m_characters) { glDeleteTextures(1, &font.textureID); }