Generate EffectId from derived type identifiers

このコミットが含まれているのは:
Sergio Pedri committed 2023-09-27 14:04:04 +02:00
1 親 c31572f68f
コミット 3303c0f2f3
6ファイル変更
+163 -17

検索条件に一致するファイルはありません

+54 -5
ファイルの表示
@@ -75,6 +75,33 @@ internal struct ImmutableArrayBuilder<T> : IDisposable
this.writer!.AddRange(items);
}
/// <summary>
/// Advances the current writer by the specified amount.
/// </summary>
/// <param name="count">The amoutn to advance by.</param>
public readonly void Advance(int count)
{
this.writer!.Advance(count);
}
/// <summary>
/// Gets the array currently in use (rented from the pool).
/// </summary>
/// <returns>The array currently in use.</returns>
public readonly T[] DangerousGetArray()
{
return this.writer!.DangerousGetArray();
}
/// <summary>
/// Ensures that the current instance has enough free space to contain a given number of new items.
/// </summary>
/// <param name="requestedSize">The minimum number of items to ensure space for.</param>
public readonly void EnsureCapacity(int requestedSize)
{
this.writer!.EnsureCapacity(requestedSize);
}
/// <summary>
/// Inserts an item to the builder at the specified index.
/// </summary>
@@ -177,6 +204,23 @@ internal struct ImmutableArrayBuilder<T> : IDisposable
this.index += items.Length;
}
/// <inheritdoc cref="ImmutableArrayBuilder{T}.Advance"/>
public void Advance(int count)
{
if (count > this.array.Length - this.index)
{
ImmutableArrayBuilder.ThrowArgumentOutOfRangeExceptionForCount();
}
this.index += count;
}
/// <inheritdoc cref="ImmutableArrayBuilder{T}.DangerousGetArray"/>
public T[] DangerousGetArray()
{
return this.array;
}
/// <inheritdoc cref="ImmutableArrayBuilder{T}.Insert"/>
public void Insert(int index, T item)
{
@@ -209,12 +253,9 @@ internal struct ImmutableArrayBuilder<T> : IDisposable
this.index = 0;
}
/// <summary>
/// Ensures that <see cref="array"/> has enough free space to contain a given number of new items.
/// </summary>
/// <param name="requestedSize">The minimum number of items to ensure space for in <see cref="array"/>.</param>
/// <inheritdoc cref="ImmutableArrayBuilder{T}.EnsureCapacity"/>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void EnsureCapacity(int requestedSize)
public void EnsureCapacity(int requestedSize)
{
if (requestedSize > this.array.Length - this.index)
{
@@ -253,4 +294,12 @@ file static class ImmutableArrayBuilder
{
throw new ArgumentOutOfRangeException("index");
}
/// <summary>
/// Throws an <see cref="ArgumentOutOfRangeException"/> for <c>"count"</c>.
/// </summary>
public static void ThrowArgumentOutOfRangeExceptionForCount()
{
throw new ArgumentOutOfRangeException("count");
}
}