diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-09-13 18:20:35 +0300 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-12-18 12:23:57 +0200 |
| commit | bb4d48fbf9d0ad6be570d9c9b052f835f3a8b0d5 (patch) | |
| tree | 7feeb721a184e7e704a7a55d3c73691297b7b7ab /kms++util/src | |
| parent | d785a753f9406bf74150e038ccf58b8b40eea932 (diff) | |
fix: Use const references to avoid unnecessary variable copying
This commit addresses cppcheck warnings about variables that can be
declared as const references (constVariableReference). These variables
were being copied unnecessarily when they could be accessed as const
references, improving performance and code clarity.
Fixed files:
- kms++util/src/cpuframebuffer.cpp: Make plane reference const in destructor
- kms++util/src/testpat.cpp: Make info and lambda parameter const references
- utils/kmstest.cpp: Make loop variable const reference in output parsing
Diffstat (limited to 'kms++util/src')
| -rw-r--r-- | kms++util/src/cpuframebuffer.cpp | 2 | ||||
| -rw-r--r-- | kms++util/src/testpat.cpp | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/kms++util/src/cpuframebuffer.cpp b/kms++util/src/cpuframebuffer.cpp index 8eac8c4..64ad531 100644 --- a/kms++util/src/cpuframebuffer.cpp +++ b/kms++util/src/cpuframebuffer.cpp @@ -26,7 +26,7 @@ CPUFramebuffer::CPUFramebuffer(uint32_t width, uint32_t height, PixelFormat form CPUFramebuffer::~CPUFramebuffer() { for (unsigned i = 0; i < m_num_planes; ++i) { - FramebufferPlane& plane = m_planes[i]; + const FramebufferPlane& plane = m_planes[i]; delete[] plane.map; } diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp index 1edf978..8444ce0 100644 --- a/kms++util/src/testpat.cpp +++ b/kms++util/src/testpat.cpp @@ -471,7 +471,7 @@ static void draw_test_pattern_part(IFramebuffer& fb, size_t start_y, size_t end_ void draw_test_pattern_multi(IFramebuffer& fb, const TestPatternOptions& options) { - auto& info = get_pixel_format_info(fb.format()); + const auto& info = get_pixel_format_info(fb.format()); uint8_t v_sub = 0; for (size_t p = 0; p < info.num_planes; ++p) v_sub = max(v_sub, info.planes[p].vsub); @@ -514,7 +514,7 @@ void draw_test_pattern_multi(IFramebuffer& fb, const TestPatternOptions& options t.join(); auto i = std::find_if(errors.begin(), errors.end(), - [](auto& e) { return e != nullptr; }); + [](const auto& e) { return e != nullptr; }); if (i != errors.end()) std::rethrow_exception(*i); } |
