mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-16 02:55:00 +00:00
Don't let fromSlice allocate when slice is empty
This commit is contained in:
parent
409193f905
commit
1b872022bb
1 changed files with 4 additions and 0 deletions
|
@ -57,6 +57,10 @@ pub const RocList = extern struct {
|
|||
}
|
||||
|
||||
pub fn fromSlice(comptime T: type, slice: []const T) RocList {
|
||||
if (slice.len == 0) {
|
||||
return RocList.empty();
|
||||
}
|
||||
|
||||
var list = allocate(@alignOf(T), slice.len, @sizeOf(T));
|
||||
|
||||
if (slice.len > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue