1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +00:00

AK: Replace C-style casts

This commit is contained in:
Sam Atkins 2023-03-07 14:28:21 +00:00 committed by Andreas Kling
parent 7d6908d9a5
commit 067d0689c5
14 changed files with 49 additions and 49 deletions

View file

@ -64,19 +64,19 @@ public:
count += popcount(byte);
}
if (++first < last) {
size_t const* ptr_large = (size_t const*)(((FlatPtr)first + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1));
if ((u8 const*)ptr_large > last)
ptr_large = (size_t const*)last;
while (first < (u8 const*)ptr_large) {
size_t const* ptr_large = reinterpret_cast<size_t const*>((reinterpret_cast<FlatPtr>(first) + sizeof(size_t) - 1) & ~(sizeof(size_t) - 1));
if (reinterpret_cast<u8 const*>(ptr_large) > last)
ptr_large = reinterpret_cast<size_t const*>(last);
while (first < reinterpret_cast<u8 const*>(ptr_large)) {
count += popcount(*first);
first++;
}
size_t const* last_large = (size_t const*)((FlatPtr)last & ~(sizeof(size_t) - 1));
size_t const* last_large = reinterpret_cast<size_t const*>(reinterpret_cast<FlatPtr>(last) & ~(sizeof(size_t) - 1));
while (ptr_large < last_large) {
count += popcount(*ptr_large);
ptr_large++;
}
for (first = (u8 const*)ptr_large; first < last; first++)
for (first = reinterpret_cast<u8 const*>(ptr_large); first < last; first++)
count += popcount(*first);
}
}
@ -100,12 +100,12 @@ public:
// We will use hint as what it is: a hint. Because we try to
// scan over entire 32 bit words, we may start searching before
// the hint!
size_t const* ptr_large = (size_t const*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1));
if ((u8 const*)ptr_large < &m_data[0]) {
size_t const* ptr_large = reinterpret_cast<size_t const*>(reinterpret_cast<FlatPtr>(&m_data[hint / 8]) & ~(sizeof(size_t) - 1));
if (reinterpret_cast<u8 const*>(ptr_large) < &m_data[0]) {
ptr_large++;
// m_data isn't aligned, check first bytes
size_t start_ptr_large = (u8 const*)ptr_large - &m_data[0];
size_t start_ptr_large = reinterpret_cast<u8 const*>(ptr_large) - &m_data[0];
size_t i = 0;
u8 byte = VALUE ? 0x00 : 0xff;
while (i < start_ptr_large && m_data[i] == byte)
@ -120,14 +120,14 @@ public:
}
size_t val_large = VALUE ? 0x0 : NumericLimits<size_t>::max();
size_t const* end_large = (size_t const*)((FlatPtr)end & ~(sizeof(size_t) - 1));
size_t const* end_large = reinterpret_cast<size_t const*>(reinterpret_cast<FlatPtr>(end) & ~(sizeof(size_t) - 1));
while (ptr_large < end_large && *ptr_large == val_large)
ptr_large++;
if (ptr_large == end_large) {
// We didn't find anything, check the remaining few bytes (if any)
u8 byte = VALUE ? 0x00 : 0xff;
size_t i = (u8 const*)ptr_large - &m_data[0];
size_t i = reinterpret_cast<u8 const*>(ptr_large) - &m_data[0];
size_t byte_count = m_size / 8;
VERIFY(i <= byte_count);
while (i < byte_count && m_data[i] == byte)
@ -137,7 +137,7 @@ public:
return {}; // We already checked from the beginning
// Try scanning before the hint
end = (u8 const*)((FlatPtr)&m_data[hint / 8] & ~(sizeof(size_t) - 1));
end = reinterpret_cast<u8 const*>(reinterpret_cast<FlatPtr>(&m_data[hint / 8]) & ~(sizeof(size_t) - 1));
hint = 0;
continue;
}
@ -154,7 +154,7 @@ public:
if constexpr (!VALUE)
val_large = ~val_large;
VERIFY(val_large != 0);
return ((u8 const*)ptr_large - &m_data[0]) * 8 + bit_scan_forward(val_large) - 1;
return (reinterpret_cast<u8 const*>(ptr_large) - &m_data[0]) * 8 + bit_scan_forward(val_large) - 1;
}
}
@ -207,7 +207,7 @@ public:
size_t bit_size = 8 * sizeof(size_t);
size_t* bitmap = (size_t*)m_data;
size_t* bitmap = reinterpret_cast<size_t*>(m_data);
// Calculating the start offset.
size_t start_bucket_index = from / bit_size;