BAN: String, Queue and Vector dont use floating point arithmetic

This commit is contained in:
Bananymous 2023-01-12 17:00:29 +02:00
parent 4ae4ad528a
commit 78da037dda
3 changed files with 3 additions and 3 deletions

View File

@ -199,7 +199,7 @@ namespace BAN
{ {
if (m_capasity >= size) if (m_capasity >= size)
return {}; return {};
size_type new_cap = BAN::Math::max<size_type>(size, m_capasity * 1.5f); size_type new_cap = BAN::Math::max<size_type>(size, m_capasity * 3 / 2);
void* new_data = BAN::allocator(new_cap); void* new_data = BAN::allocator(new_cap);
if (new_data == nullptr) if (new_data == nullptr)
return Error::FromString("String: Could not allocate memory"); return Error::FromString("String: Could not allocate memory");

View File

@ -95,7 +95,7 @@ namespace BAN
if (m_capacity > size) if (m_capacity > size)
return {}; return {};
size_type new_cap = BAN::Math::max<size_type>(m_capacity * 1.5f, m_capacity + 1); size_type new_cap = BAN::Math::max<size_type>(size, m_capacity * 3 / 2);
void* new_data = BAN::allocator(new_cap * sizeof(T)); void* new_data = BAN::allocator(new_cap * sizeof(T));
if (new_data == nullptr) if (new_data == nullptr)
return Error::FromString("Queue: Could not allocate memory"); return Error::FromString("Queue: Could not allocate memory");

View File

@ -207,7 +207,7 @@ namespace BAN
{ {
if (m_capasity >= size) if (m_capasity >= size)
return {}; return {};
size_type new_cap = BAN::Math::max<size_type>(size, m_capasity * 1.5f); size_type new_cap = BAN::Math::max<size_type>(size, m_capasity * 3 / 2);
void* new_data = BAN::allocator(new_cap * sizeof(T)); void* new_data = BAN::allocator(new_cap * sizeof(T));
if (new_data == nullptr) if (new_data == nullptr)
return Error::FromString("Vector: Could not allocate memory"); return Error::FromString("Vector: Could not allocate memory");