diff --git a/libluna/include/luna/Vector.h b/libluna/include/luna/Vector.h index c73d3989..65c73f19 100644 --- a/libluna/include/luna/Vector.h +++ b/libluna/include/luna/Vector.h @@ -201,6 +201,13 @@ template class Vector m_data = nullptr; } + void clear_data() + { + for (usize i = 0; i < m_size; i++) { m_data[i].~T(); } + + m_size = 0; + } + Result> shallow_copy() { Vector other; diff --git a/libluna/src/Base64.cpp b/libluna/src/Base64.cpp index a40add49..25cdaf8e 100644 --- a/libluna/src/Base64.cpp +++ b/libluna/src/Base64.cpp @@ -118,6 +118,7 @@ namespace Base64 } Vector chars_read; + TRY(chars_read.try_reserve(4)); for (const auto& c : data) { @@ -134,7 +135,7 @@ namespace Base64 if (chars_read.size() == 4) { TRY(decode_base64_buffer(chars_read, buf)); - chars_read.clear(); + chars_read.clear_data(); } }