From 583d6741ed32a8bbeafb900aac5f47f2761f8d09 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 21 Jul 2021 18:08:27 +0200 Subject: [PATCH] AK: Sprinkle [[nodiscard]] on AK::Bitmap --- AK/Bitmap.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/AK/Bitmap.h b/AK/Bitmap.h index 781e3476158..9e0ad3f2a87 100644 --- a/AK/Bitmap.h +++ b/AK/Bitmap.h @@ -37,8 +37,8 @@ public: { } - BitmapView view() { return { m_data, m_size }; } - const BitmapView view() const { return { m_data, m_size }; } + [[nodiscard]] BitmapView view() { return { m_data, m_size }; } + [[nodiscard]] BitmapView const view() const { return { m_data, m_size }; } Bitmap(Bitmap&& other) : m_data(exchange(other.m_data, nullptr)) @@ -64,10 +64,10 @@ public: m_data = nullptr; } - size_t size() const { return m_size; } - size_t size_in_bytes() const { return ceil_div(m_size, static_cast(8)); } + [[nodiscard]] size_t size() const { return m_size; } + [[nodiscard]] size_t size_in_bytes() const { return ceil_div(m_size, static_cast(8)); } - bool get(size_t index) const + [[nodiscard]] bool get(size_t index) const { VERIFY(index < m_size); return 0 != (m_data[index / 8] & (1u << (index % 8))); @@ -82,13 +82,13 @@ public: m_data[index / 8] &= static_cast(~(1u << (index % 8))); } - size_t count_slow(bool value) const { return count_in_range(0, m_size, value); } - size_t count_in_range(size_t start, size_t len, bool value) const { return view().count_in_range(start, len, value); } + [[nodiscard]] size_t count_slow(bool value) const { return count_in_range(0, m_size, value); } + [[nodiscard]] size_t count_in_range(size_t start, size_t len, bool value) const { return view().count_in_range(start, len, value); } - bool is_null() const { return !m_data; } + [[nodiscard]] bool is_null() const { return !m_data; } - u8* data() { return m_data; } - const u8* data() const { return m_data; } + [[nodiscard]] u8* data() { return m_data; } + [[nodiscard]] u8 const* data() const { return m_data; } void grow(size_t size, bool default_value) {