mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
31 lines
774 B
C
31 lines
774 B
C
module std::core::array;
|
|
|
|
macro tconcat(arr1, arr2)
|
|
{
|
|
var $Type = $typeof(arr1[0]);
|
|
$Type[] result = array::talloc($Type, arr1.len + arr2.len);
|
|
if (arr1.len > 0)
|
|
{
|
|
mem::copy(result.ptr, &arr1[0], arr1.len * $Type.sizeof, $Type.alignof, $Type.alignof);
|
|
}
|
|
if (arr2.len > 0)
|
|
{
|
|
mem::copy(&result[arr1.len], &arr2[0], arr2.len * $Type.sizeof, $Type.alignof, $Type.alignof);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
macro concat(arr1, arr2)
|
|
{
|
|
var $Type = $typeof(arr1[0]);
|
|
$Type[] result = array::alloc($Type, arr1.len + arr2.len);
|
|
if (arr1.len > 0)
|
|
{
|
|
mem::copy(result.ptr, &arr1[0], arr1.len * $Type.sizeof, $Type.alignof, $Type.alignof);
|
|
}
|
|
if (arr2.len > 0)
|
|
{
|
|
mem::copy(&result[arr1.len], &arr2[0], arr2.len * $Type.sizeof, $Type.alignof, $Type.alignof);
|
|
}
|
|
return result;
|
|
} |