Prechádzať zdrojové kódy

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

Andreas Kling 4 rokov pred
rodič
commit
583d6741ed
1 zmenil súbory, kde vykonal 10 pridanie a 10 odobranie
  1. 10 10
      AK/Bitmap.h

+ 10 - 10
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<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)
     {