feat: Replaces params array with params ReadOnlySpan (#2125)
This commit is contained in:
parent
90059c5e74
commit
279b10dd0f
15 changed files with 36 additions and 35 deletions
|
|
@ -423,7 +423,7 @@ public partial class Container : Item
|
|||
return false;
|
||||
}
|
||||
|
||||
public virtual bool TryDropItems(Mobile from, bool sendFullMessage, params Item[] droppedItems)
|
||||
public virtual bool TryDropItems(Mobile from, bool sendFullMessage, params ReadOnlySpan<Item> droppedItems)
|
||||
{
|
||||
var dropItems = new List<Item>();
|
||||
var stackItems = new List<ItemStackEntry>();
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
|||
public const int MinZ = sbyte.MinValue;
|
||||
public const int MaxZ = sbyte.MaxValue + 1;
|
||||
|
||||
public Region(string name, Map map, int priority, params Rectangle2D[] area) : this(
|
||||
public Region(string name, Map map, int priority, params ReadOnlySpan<Rectangle2D> area) : this(
|
||||
name,
|
||||
map,
|
||||
priority,
|
||||
|
|
@ -147,7 +147,7 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
|||
public Region(string name, Map map, Region parent, int priority, params Rectangle3D[] area) : this(name, map, parent, area) =>
|
||||
Priority = priority;
|
||||
|
||||
public Region(string name, Map map, Region parent, params Rectangle2D[] area) : this(
|
||||
public Region(string name, Map map, Region parent, params ReadOnlySpan<Rectangle2D> area) : this(
|
||||
name,
|
||||
map,
|
||||
parent,
|
||||
|
|
@ -314,7 +314,7 @@ public class Region : IComparable<Region>, IValueLinkListNode<Region>
|
|||
public static Rectangle3D ConvertTo3D(Rectangle2D rect) =>
|
||||
new(new Point3D(rect.Start, MinZ), new Point3D(rect.End, MaxZ));
|
||||
|
||||
public static Rectangle3D[] ConvertTo3D(Rectangle2D[] rects)
|
||||
public static Rectangle3D[] ConvertTo3D(ReadOnlySpan<Rectangle2D> rects)
|
||||
{
|
||||
var ret = new Rectangle3D[rects.Length];
|
||||
|
||||
|
|
|
|||
|
|
@ -745,7 +745,7 @@ public static partial class Utility
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomList<T>(params T[] list) => list.RandomElement();
|
||||
public static T RandomList<T>(params ReadOnlySpan<T> list) => list.RandomElement();
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T RandomElement<T>(this ReadOnlySpan<T> list) => list.Length == 0 ? default : list[Random(list.Length)];
|
||||
|
|
@ -1305,15 +1305,15 @@ public static partial class Utility
|
|||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T[] Combine<T>(this IList<T> source, params IList<T>[] arrays) =>
|
||||
public static T[] Combine<T>(this IList<T> source, params ReadOnlySpan<IList<T>> arrays) =>
|
||||
source.Combine(false, arrays);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T[] CombinePooled<T>(this IList<T> source, params IList<T>[] arrays) =>
|
||||
public static T[] CombinePooled<T>(this IList<T> source, params ReadOnlySpan<IList<T>> arrays) =>
|
||||
source.Combine(true, arrays);
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T[] Combine<T>(this IList<T> source, bool pooled, params IList<T>[] arrays)
|
||||
public static T[] Combine<T>(this IList<T> source, bool pooled, params ReadOnlySpan<IList<T>> arrays)
|
||||
{
|
||||
var totalLength = source.Count;
|
||||
foreach (var arr in arrays)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue