Compare commits

..

No commits in common. "298c7bfe94d5ff304128a369c97cdeeec8e27ec3" and "5394e8de679370db674aabcc94ddb38e7c6c5ec2" have entirely different histories.

2 changed files with 4 additions and 3 deletions

View File

@ -480,7 +480,7 @@ export namespace core {
void copy(slice<u8> const & target, slice<u8 const> const & origin) { void copy(slice<u8> const & target, slice<u8 const> const & origin) {
if (target.length < origin.length) core::unreachable(); if (target.length < origin.length) core::unreachable();
for (usize i = 0; i < origin.length; i += 1) target[i] = origin[i]; for (usize i = 0; i < target.length; i += 1) target[i] = origin[i];
} }
/** /**

View File

@ -70,7 +70,8 @@ export namespace core {
usize const updated_fill = this->filled + source_elements.length; usize const updated_fill = this->filled + source_elements.length;
if (updated_fill >= this->elements.length) { if (updated_fill >= this->elements.length) {
append_result const result = this->reserve(updated_fill); append_result const result =
this->reserve(max(this->elements.length, updated_fill));
if (result != append_result::ok) return result; if (result != append_result::ok) return result;
} }
@ -154,7 +155,7 @@ export namespace core {
* `initial_capacity` argument. * `initial_capacity` argument.
*/ */
append_result reserve(usize capacity) { append_result reserve(usize capacity) {
usize const requested_capacity = this->filled + capacity; usize const requested_capacity = this->elements.length + capacity;
if (this->is_dynamic()) { if (this->is_dynamic()) {
// Grow dynamic buffer (bailing out if failed). // Grow dynamic buffer (bailing out if failed).