From 78da037dda5df4c9c7349bff7d3547f70af0a96b Mon Sep 17 00:00:00 2001 From: Bananymous Date: Thu, 12 Jan 2023 17:00:29 +0200 Subject: [PATCH] BAN: String, Queue and Vector dont use floating point arithmetic --- BAN/BAN/String.cpp | 2 +- BAN/include/BAN/Queue.h | 2 +- BAN/include/BAN/Vector.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BAN/BAN/String.cpp b/BAN/BAN/String.cpp index cf71211cc1..4f11998101 100644 --- a/BAN/BAN/String.cpp +++ b/BAN/BAN/String.cpp @@ -199,7 +199,7 @@ namespace BAN { if (m_capasity >= size) return {}; - size_type new_cap = BAN::Math::max(size, m_capasity * 1.5f); + size_type new_cap = BAN::Math::max(size, m_capasity * 3 / 2); void* new_data = BAN::allocator(new_cap); if (new_data == nullptr) return Error::FromString("String: Could not allocate memory"); diff --git a/BAN/include/BAN/Queue.h b/BAN/include/BAN/Queue.h index 506f599797..4ba475bcdf 100644 --- a/BAN/include/BAN/Queue.h +++ b/BAN/include/BAN/Queue.h @@ -95,7 +95,7 @@ namespace BAN if (m_capacity > size) return {}; - size_type new_cap = BAN::Math::max(m_capacity * 1.5f, m_capacity + 1); + size_type new_cap = BAN::Math::max(size, m_capacity * 3 / 2); void* new_data = BAN::allocator(new_cap * sizeof(T)); if (new_data == nullptr) return Error::FromString("Queue: Could not allocate memory"); diff --git a/BAN/include/BAN/Vector.h b/BAN/include/BAN/Vector.h index e7d63fd5c2..3e2af8dbea 100644 --- a/BAN/include/BAN/Vector.h +++ b/BAN/include/BAN/Vector.h @@ -207,7 +207,7 @@ namespace BAN { if (m_capasity >= size) return {}; - size_type new_cap = BAN::Math::max(size, m_capasity * 1.5f); + size_type new_cap = BAN::Math::max(size, m_capasity * 3 / 2); void* new_data = BAN::allocator(new_cap * sizeof(T)); if (new_data == nullptr) return Error::FromString("Vector: Could not allocate memory");