mirror of
https://github.com/odin-lang/Odin.git
synced 2025-12-29 01:14:40 +00:00
Make for in logic a bit more generic
This commit is contained in:
@@ -102,13 +102,20 @@ Slice<T> slice_clone_from_array(gbAllocator const &allocator, Array<T> const &a)
|
||||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
void slice_copy(Slice<T> *slice, Slice<T> const &data) {
|
||||
isize n = gb_min(slice->count, data.count);
|
||||
gb_memmove(slice->data, data.data, gb_size_of(T)*n);
|
||||
}
|
||||
template <typename T>
|
||||
void slice_copy(Slice<T> *slice, Slice<T> const &data, isize offset) {
|
||||
gb_memmove(slice->data+offset, data.data, gb_size_of(T)*data.count);
|
||||
isize n = gb_clamp(slice->count-offset, 0, data.count);
|
||||
gb_memmove(slice->data+offset, data.data, gb_size_of(T)*n);
|
||||
}
|
||||
template <typename T>
|
||||
void slice_copy(Slice<T> *slice, Slice<T> const &data, isize offset, isize count) {
|
||||
gb_memmove(slice->data+offset, data.data, gb_size_of(T)*gb_min(data.count, count));
|
||||
isize n = gb_clamp(slice->count-offset, 0, gb_min(data.count, count));
|
||||
gb_memmove(slice->data+offset, data.data, gb_size_of(T)*n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user