From 6974203e34433fca78b2c946f5931ab2b7dc9126 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 6 Sep 2021 00:55:42 +0200 Subject: [PATCH 1/2] Prevented unnecessary allocations --- RGB.NET.Core/Decorators/AbstractDecorateable.cs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/RGB.NET.Core/Decorators/AbstractDecorateable.cs b/RGB.NET.Core/Decorators/AbstractDecorateable.cs index 8acfc54..50602ae 100644 --- a/RGB.NET.Core/Decorators/AbstractDecorateable.cs +++ b/RGB.NET.Core/Decorators/AbstractDecorateable.cs @@ -14,13 +14,18 @@ namespace RGB.NET.Core private readonly List _decorators = new(); /// - public IReadOnlyCollection Decorators + public IReadOnlyCollection Decorators { get; } + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + protected AbstractDecoratable() { - get - { - lock (_decorators) - return new ReadOnlyCollection(_decorators); - } + Decorators = new ReadOnlyCollection(_decorators); } #endregion From d487bee35c3163b72ad11c8b721727e51e1e83e9 Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Mon, 6 Sep 2021 00:55:48 +0200 Subject: [PATCH 2/2] Fixed code warning --- RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs b/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs index a7606af..d7f46be 100644 --- a/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs +++ b/RGB.NET.Devices.DMX/E131/E131DeviceInfo.cs @@ -68,7 +68,7 @@ namespace RGB.NET.Devices.DMX.E131 this.Hostname = deviceDefinition.Hostname; this.Port = deviceDefinition.Port; this.Universe = deviceDefinition.Universe; - + byte[]? cid = deviceDefinition.CID; if ((cid == null) || (cid.Length != CID_LENGTH)) { @@ -76,7 +76,7 @@ namespace RGB.NET.Devices.DMX.E131 new Random().NextBytes(cid); } - CID = cid!; + CID = cid; DeviceName = DeviceHelper.CreateDeviceName(Manufacturer, Model); }