BLI: make more integer type conversions explicit
This commit is contained in:
parent
394318da74
commit
bb7c858598
|
@ -42,7 +42,7 @@ namespace BLI {
|
|||
template<typename Item, uint32_t ItemsInSmallStorage = 1, typename Allocator = GuardedAllocator>
|
||||
class OpenAddressingArray {
|
||||
private:
|
||||
static constexpr auto slots_per_item = Item::slots_per_item;
|
||||
static constexpr uint32_t slots_per_item = Item::slots_per_item;
|
||||
static constexpr float max_load_factor = 0.5f;
|
||||
|
||||
/* Invariants:
|
||||
|
@ -74,10 +74,10 @@ class OpenAddressingArray {
|
|||
public:
|
||||
explicit OpenAddressingArray(uint8_t item_exponent = 0)
|
||||
{
|
||||
m_slots_total = (1 << item_exponent) * slots_per_item;
|
||||
m_slots_total = ((uint32_t)1 << item_exponent) * slots_per_item;
|
||||
m_slots_set_or_dummy = 0;
|
||||
m_slots_dummy = 0;
|
||||
m_slots_usable = m_slots_total * max_load_factor;
|
||||
m_slots_usable = (uint32_t)((float)m_slots_total * max_load_factor);
|
||||
m_slot_mask = m_slots_total - 1;
|
||||
m_item_amount = m_slots_total / slots_per_item;
|
||||
m_item_exponent = item_exponent;
|
||||
|
@ -87,7 +87,7 @@ class OpenAddressingArray {
|
|||
}
|
||||
else {
|
||||
m_items = (Item *)m_allocator.allocate_aligned(
|
||||
sizeof(Item) * m_item_amount, std::alignment_of<Item>::value, __func__);
|
||||
(uint32_t)sizeof(Item) * m_item_amount, std::alignment_of<Item>::value, __func__);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < m_item_amount; i++) {
|
||||
|
@ -176,7 +176,7 @@ class OpenAddressingArray {
|
|||
{
|
||||
float min_total_slots = (float)min_usable_slots / max_load_factor;
|
||||
uint32_t min_total_items = (uint32_t)std::ceil(min_total_slots / (float)slots_per_item);
|
||||
uint8_t item_exponent = log2_ceil_u(min_total_items);
|
||||
uint8_t item_exponent = (uint8_t)log2_ceil_u(min_total_items);
|
||||
OpenAddressingArray grown(item_exponent);
|
||||
grown.m_slots_set_or_dummy = this->slots_set();
|
||||
return grown;
|
||||
|
|
|
@ -88,7 +88,7 @@ template<typename T, typename Allocator = GuardedAllocator> class SetVector {
|
|||
uint index() const
|
||||
{
|
||||
BLI_assert(this->is_set());
|
||||
return m_value;
|
||||
return (uint)m_value;
|
||||
}
|
||||
|
||||
int32_t &index_ref()
|
||||
|
@ -99,7 +99,7 @@ template<typename T, typename Allocator = GuardedAllocator> class SetVector {
|
|||
void set_index(uint index)
|
||||
{
|
||||
BLI_assert(!this->is_set());
|
||||
m_value = index;
|
||||
m_value = (int32_t)index;
|
||||
}
|
||||
|
||||
void set_dummy()
|
||||
|
|
|
@ -52,7 +52,7 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
|
|||
#ifdef DEBUG
|
||||
/* Storing size in debug builds, because it makes debugging much easier sometimes. */
|
||||
uint m_debug_size;
|
||||
# define UPDATE_VECTOR_SIZE(ptr) (ptr)->m_debug_size = (ptr)->m_end - (ptr)->m_begin
|
||||
# define UPDATE_VECTOR_SIZE(ptr) (ptr)->m_debug_size = (uint)((ptr)->m_end - (ptr)->m_begin)
|
||||
#else
|
||||
# define UPDATE_VECTOR_SIZE(ptr) ((void)0)
|
||||
#endif
|
||||
|
@ -387,8 +387,8 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
|
|||
*/
|
||||
uint size() const
|
||||
{
|
||||
BLI_assert(m_debug_size == m_end - m_begin);
|
||||
return m_end - m_begin;
|
||||
BLI_assert(m_debug_size == (uint)(m_end - m_begin));
|
||||
return (uint)(m_end - m_begin);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -539,7 +539,7 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
|
|||
|
||||
uint capacity() const
|
||||
{
|
||||
return m_capacity_end - m_begin;
|
||||
return (uint)(m_capacity_end - m_begin);
|
||||
}
|
||||
|
||||
BLI_NOINLINE void grow(uint min_capacity)
|
||||
|
@ -554,7 +554,7 @@ template<typename T, uint N = 4, typename Allocator = GuardedAllocator> class Ve
|
|||
uint size = this->size();
|
||||
|
||||
T *new_array = (T *)m_allocator.allocate_aligned(
|
||||
min_capacity * sizeof(T), std::alignment_of<T>::value, __func__);
|
||||
min_capacity * (uint)sizeof(T), std::alignment_of<T>::value, __func__);
|
||||
uninitialized_relocate_n(m_begin, size, new_array);
|
||||
|
||||
if (!this->is_small()) {
|
||||
|
|
Loading…
Reference in New Issue