AK: Sprinkle [[nodiscard]] on AK::Bitmap

This commit is contained in:
Andreas Kling 2021-07-21 18:08:27 +02:00
parent a5c9a31001
commit 583d6741ed
Notes: sideshowbarker 2024-07-18 08:38:24 +09:00

View file

@ -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<size_t>(8)); }
[[nodiscard]] size_t size() const { return m_size; }
[[nodiscard]] size_t size_in_bytes() const { return ceil_div(m_size, static_cast<size_t>(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<u8>(~(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)
{