From: Brendan Hansen Date: Thu, 4 Jan 2024 17:40:31 +0000 (-0600) Subject: bugfix: `slice.group_by` with empty array X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=3bb145cb5ee111317ce774e15a2705bd49893cd5;p=onyx.git bugfix: `slice.group_by` with empty array --- diff --git a/core/container/slice.onyx b/core/container/slice.onyx index 169d5172..4eb7ba7c 100644 --- a/core/container/slice.onyx +++ b/core/container/slice.onyx @@ -637,6 +637,8 @@ group_by :: macro (arr: [] $T, comp: (T, T) -> bool, allocator := context.alloca #overload group_by :: macro (arr_: [] $T, comp: Code, allocator := context.allocator) -> [..] [] T { out := make([..] [] T, allocator); + if arr_.count == 0 do return out; + start := 0; arr := arr_; for i: 1 .. arr.count {