From a66f859fb49b2d31809767aaa8b4d8872b73c062 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Wed, 29 Dec 2021 11:58:27 +0000 Subject: Minor improvements to `core:container/small_array` --- core/container/small_array/small_array.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/container/small_array') diff --git a/core/container/small_array/small_array.odin b/core/container/small_array/small_array.odin index 60c22837c..d09e0c81c 100644 --- a/core/container/small_array/small_array.odin +++ b/core/container/small_array/small_array.odin @@ -42,16 +42,16 @@ resize :: proc(a: ^$A/Small_Array, length: int) { push_back :: proc(a: ^$A/Small_Array($N, $T), item: T) -> bool { - if a.len < builtin.len(a.data) { + if a.len < cap(a^) { + a.data[a.len] = item a.len += 1 - a.data[a.len-1] = item return true } return false } push_front :: proc(a: ^$A/Small_Array($N, $T), item: T) -> bool { - if a.len < builtin.len(a.data) { + if a.len < cap(a^) { a.len += 1 data := slice(a) copy(data[1:], data[:]) -- cgit v1.2.3