projects
/
onyx.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9970eac
)
bugfix: `slice.group_by` with empty array
author
Brendan Hansen
<brendan.f.hansen@gmail.com>
Thu, 4 Jan 2024 17:40:31 +0000
(11:40 -0600)
committer
Brendan Hansen
<brendan.f.hansen@gmail.com>
Thu, 4 Jan 2024 17:40:31 +0000
(11:40 -0600)
core/container/slice.onyx
patch
|
blob
|
history
diff --git
a/core/container/slice.onyx
b/core/container/slice.onyx
index 169d5172cca5d4b2908b2d15d7a82b39d04ce444..4eb7ba7cb461d7622f369601c5b14a2b5b0e4d65 100644
(file)
--- 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 {