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

Remove CustomUpdateData heap allocation in OnUpdate hot path. #403

Merged
merged 2 commits into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 RGB.NET.Core/Update/AbstractUpdateTrigger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public abstract class AbstractUpdateTrigger : AbstractBindable, IUpdateTrigger
/// Invokes the <see cref="Starting"/>-event.
/// </summary>
/// <param name="updateData">Optional custom-data passed to the subscribers of the <see cref="Starting"/>.event.</param>
protected virtual void OnStartup(CustomUpdateData? updateData = null) => Starting?.Invoke(this, updateData ?? new CustomUpdateData());
protected virtual void OnStartup(CustomUpdateData? updateData = null) => Starting?.Invoke(this, updateData ?? CustomUpdateData.Empty);

/// <summary>
/// Invokes the <see cref="Update"/>-event.
/// </summary>
/// <param name="updateData">Optional custom-data passed to the subscribers of the <see cref="Update"/>.event.</param>
protected virtual void OnUpdate(CustomUpdateData? updateData = null) => Update?.Invoke(this, updateData ?? new CustomUpdateData());
protected virtual void OnUpdate(CustomUpdateData? updateData = null) => Update?.Invoke(this, updateData ?? CustomUpdateData.Empty);

/// <inheritdoc />
public abstract void Start();
Expand Down
1 change: 1 addition & 0 deletions RGB.NET.Core/Update/CustomUpdateData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public interface ICustomUpdateData
public sealed class CustomUpdateData : ICustomUpdateData
{
#region Properties & Fields
public static readonly CustomUpdateData Empty = new CustomUpdateData();
stonstad marked this conversation as resolved.
Show resolved Hide resolved

private readonly Dictionary<string, object?> _data = [];

Expand Down