// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using System;
namespace SixLabors.ImageSharp.Drawing.Helpers {
///
/// Extension methods for arrays.
///
internal static class ArrayExtensions
{
///
/// Concatenates two arrays into one.
///
/// The element type.
/// The first source array.
/// The second source array.
///
/// A new array containing the elements of both source arrays, or
/// when is empty.
///
public static T[] Concat(this T[] source1, T[] source2)
{
if (source2 is null || source2.Length == 0)
{
return source1;
}
T[] target = new T[source1.Length + source2.Length];
source1.AsSpan().CopyTo(target);
source2.AsSpan().CopyTo(target.AsSpan(source1.Length));
return target;
}
}
}