mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-03-16 18:36:22 +00:00
AK: Add Bitmap::set_range()
Add set_range() which sets a range of bits to requested value. Fix code style.
This commit is contained in:
12
AK/Bitmap.h
12
AK/Bitmap.h
@@ -94,6 +94,12 @@ public:
|
||||
else
|
||||
m_data[index / 8] &= static_cast<u8>(~(1u << (index % 8)));
|
||||
}
|
||||
void set_range(size_t start, size_t len, bool value)
|
||||
{
|
||||
for (size_t index = start; index < start + len; ++index) {
|
||||
set(index, value);
|
||||
}
|
||||
}
|
||||
|
||||
u8* data() { return m_data; }
|
||||
const u8* data() const { return m_data; }
|
||||
@@ -136,8 +142,7 @@ public:
|
||||
while (i < m_size / 8 && m_data[i] == 0x00)
|
||||
i++;
|
||||
|
||||
size_t j = 0;
|
||||
for (j = i * 8; j < m_size; j++) {
|
||||
for (size_t j = i * 8; j < m_size; j++) {
|
||||
if (get(j))
|
||||
return j;
|
||||
}
|
||||
@@ -151,8 +156,7 @@ public:
|
||||
while (i < m_size / 8 && m_data[i] == 0xff)
|
||||
i++;
|
||||
|
||||
size_t j = 0;
|
||||
for (j = i * 8; j < m_size; j++)
|
||||
for (size_t j = i * 8; j < m_size; j++)
|
||||
if (!get(j))
|
||||
return j;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user