Don't let fromSlice allocate when slice is empty

This commit is contained in:
Richard Feldman 2022-07-02 11:43:09 -04:00
parent 409193f905
commit 1b872022bb
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798

View file

@ -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) {