Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer improvements #76

Merged
merged 4 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Bearded.Graphics/Core/BufferStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ public void Add(T item0, T item1, T item2, T item3)
IsDirty = true;
}

public void Add(T[] items)
public void Add(ReadOnlySpan<T> items)
{
var newCount = Count + items.Length;
ensureCapacity(newCount);
Array.Copy(items, 0, data, Count, items.Length);
items.CopyTo(data.AsSpan(Count));
Count = newCount;
IsDirty = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Bearded.Graphics/Pipelines/Pipeline.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public static partial class Pipeline
{
public static IPipeline<TState> Then<TState>(this IPipeline<TState> basePipeline, IPipeline<TState> continuation)
{
return new Composite<TState>(basePipeline, continuation);
return new Composite<TState>([basePipeline, continuation]);
}

public static IPipeline<TStateOuter> Elevate<TStateInner, TStateOuter>(
Expand Down
6 changes: 6 additions & 0 deletions Bearded.Graphics/Pipelines/Pipeline.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Collections.Generic;
using Bearded.Graphics.Pipelines.Steps;

namespace Bearded.Graphics.Pipelines
Expand All @@ -18,5 +19,10 @@ public static IPipeline<TState> InOrder(params IPipeline<TState>[] steps)
{
return new Composite<TState>(steps);
}

public static IPipeline<TState> InOrder(IEnumerable<IPipeline<TState>> steps)
{
return new Composite<TState>(steps);
}
}
}
9 changes: 2 additions & 7 deletions Bearded.Graphics/Pipelines/Steps/Composite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,10 @@

namespace Bearded.Graphics.Pipelines.Steps
{
sealed class Composite<TState> : IPipeline<TState>
sealed class Composite<TState>(IEnumerable<IPipeline<TState>> steps) : IPipeline<TState>
{
private bool flattened;
private ImmutableArray<IPipeline<TState>> steps;

public Composite(params IPipeline<TState>[] steps)
{
this.steps = steps.ToImmutableArray();
}
private ImmutableArray<IPipeline<TState>> steps = steps.ToImmutableArray();

public void Execute(TState state)
{
Expand Down
Loading