aboutsummaryrefslogtreecommitdiff
path: root/core/slice
diff options
context:
space:
mode:
authorBazzagibbs <bazzagibbsdev@gmail.com>2024-11-11 14:04:59 +1100
committerBazzagibbs <bazzagibbsdev@gmail.com>2024-11-11 14:04:59 +1100
commitcb0c1663b77022c90d8d645a62e47184399ea46b (patch)
treeb298568d6f2157aae6605c01df455e38573f923c /core/slice
parentda196a2b74f58be1762d496942fea83371c96d03 (diff)
Add core:slice.size to get the byte size of a slice's backing data
Diffstat (limited to 'core/slice')
-rw-r--r--core/slice/slice.odin6
1 files changed, 6 insertions, 0 deletions
diff --git a/core/slice/slice.odin b/core/slice/slice.odin
index cd12a8c70..c31edf281 100644
--- a/core/slice/slice.odin
+++ b/core/slice/slice.odin
@@ -471,6 +471,12 @@ is_empty :: proc(a: $T/[]$E) -> bool {
return len(a) == 0
}
+// Gets the byte size of the backing data
+@(require_results)
+size :: proc "contextless" (a: $T/[]$E) -> int {
+ return len(a) * size_of(E)
+}
+
@(require_results)