1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 10:08:31 +00:00

Compare commits

...

3 Commits

Author SHA1 Message Date
71f1115c31
Merge pull request #403 from stonstad/Contributions
Remove CustomUpdateData heap allocation in OnUpdate hot path.
2024-11-03 15:44:03 +01:00
Shaun Tonstad
da51871e04
Update RGB.NET.Core/Update/CustomUpdateData.cs
Co-authored-by: DarthAffe <darthaffe@wyrez.org>
2024-10-29 20:19:29 -05:00
Shaun Tonstad
c34435b958 Remove CustomUpdateData heap allocation in OnUpdate hot path. Added CustomUpdateData.Empty property.
Remove CustomUpdateData heap allocation in OnUpdate hot path. Added CustomUpdateData.Empty property.
2024-10-12 13:01:53 -05:00
2 changed files with 5 additions and 2 deletions

View File

@ -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();

View File

@ -52,6 +52,9 @@ public sealed class CustomUpdateData : ICustomUpdateData
{
#region Properties & Fields
// ReSharper disable once InconsistentNaming
public static readonly CustomUpdateData Empty = new();
private readonly Dictionary<string, object?> _data = [];
#endregion