Avoid some struct copying during array building

This commit is contained in:
Steve Sanderson 2018-01-23 23:50:21 -08:00
parent 6e4d0dbca4
commit 9da3260eb7
3 changed files with 4 additions and 4 deletions

View File

@ -45,8 +45,8 @@ namespace Microsoft.Blazor.RenderTree
/// Appends a new item, automatically resizing the underlying array if necessary.
/// </summary>
/// <param name="item">The item to append.</param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Append(T item)
[MethodImpl(MethodImplOptions.AggressiveInlining)] // Just like System.Collections.Generic.List<T>
public void Append(in T item)
{
if (_itemsInUse == _items.Length)
{

View File

@ -159,7 +159,7 @@ namespace Microsoft.Blazor.RenderTree
public ArrayRange<RenderTreeNode> GetNodes() =>
_entries.ToRange();
private void Append(RenderTreeNode node)
private void Append(in RenderTreeNode node)
{
_entries.Append(node);

View File

@ -286,7 +286,7 @@ namespace Microsoft.Blazor.RenderTree
return index;
}
private void Append(RenderTreeEdit entry)
private void Append(in RenderTreeEdit entry)
{
if (entry.Type == RenderTreeEditType.StepOut)
{