diff --git a/deps/ox/src/ox/std/vector.hpp b/deps/ox/src/ox/std/vector.hpp index ab45828f..cfb6c487 100644 --- a/deps/ox/src/ox/std/vector.hpp +++ b/deps/ox/src/ox/std/vector.hpp @@ -219,10 +219,11 @@ bool Vector::contains(T v) const noexcept { template void Vector::insert(std::size_t pos, const T &val) noexcept { + // TODO: insert should ideally have its own expandCap if (m_size == m_cap) { expandCap(m_cap ? m_cap * 2 : 100); } - for (auto i = m_size; i > pos; i--) { + for (auto i = m_size; i > pos; --i) { m_items[i] = m_items[i - 1]; } m_items[pos] = val; @@ -280,7 +281,7 @@ void Vector::expandCap(std::size_t cap) noexcept { for (std::size_t i = itRange; i < m_cap; i++) { new (&m_items[i]) T; } - delete[] reinterpret_cast*>(m_items); + delete[] reinterpret_cast*>(oldItems); } }