From 11c4066159e12ff630673c5fd94b37fb8c0f9102 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 7 Dec 2020 12:21:11 +0100 Subject: Cleanup: partial Clang-Tidy modernize-loop-convert Modernize loops by using the `for(type variable : container)` syntax. Some loops were trivial to fix, whereas others required more attention to avoid semantic changes. I couldn't address all old-style loops, so this commit doesn't enable the `modernize-loop-convert` rule. Although Clang-Tidy's auto-fixer prefers to use `auto` for the loop variable declaration, I made as many declarations as possible explicit. To me this increases local readability, as you don't need to fully understand the container in order to understand the loop variable type. No functional changes. --- source/blender/imbuf/intern/dds/ColorBlock.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'source/blender/imbuf/intern/dds/ColorBlock.cpp') diff --git a/source/blender/imbuf/intern/dds/ColorBlock.cpp b/source/blender/imbuf/intern/dds/ColorBlock.cpp index 7c8b7c1d345..00fa0111d1c 100644 --- a/source/blender/imbuf/intern/dds/ColorBlock.cpp +++ b/source/blender/imbuf/intern/dds/ColorBlock.cpp @@ -150,12 +150,12 @@ static inline uint8 component(Color32 c, uint i) void ColorBlock::swizzle(uint x, uint y, uint z, uint w) { - for (int i = 0; i < 16; i++) { - Color32 c = m_color[i]; - m_color[i].r = component(c, x); - m_color[i].g = component(c, y); - m_color[i].b = component(c, z); - m_color[i].a = component(c, w); + for (Color32 &color : m_color) { + const Color32 c = color; + color.r = component(c, x); + color.g = component(c, y); + color.b = component(c, z); + color.a = component(c, w); } } @@ -243,8 +243,8 @@ Color32 ColorBlock::averageColor() const /** Return true if the block is not fully opaque. */ bool ColorBlock::hasAlpha() const { - for (uint i = 0; i < 16; i++) { - if (m_color[i].a != 255) { + for (const auto &i : m_color) { + if (i.a != 255) { return true; } } -- cgit v1.2.3