Replaced AsReadOnly property getters with regular properties

Should reduce allocations
This commit is contained in:
Diogo Trindade committed 2021-09-04 19:41:59 +01:00
1 parent 7ad7eaad89
commit 0b370f261c
21 files changed
+84 -42

No files matched your search

+7 -3
View File
@@ -49,6 +49,10 @@ namespace Artemis.Core.Services
_devices = new List<ArtemisDevice>();
_ledMap = new Dictionary<Led, ArtemisLed>();
EnabledDevices = new ReadOnlyCollection<ArtemisDevice>(_enabledDevices);
Devices = new ReadOnlyCollection<ArtemisDevice>(_devices);
LedMap = new ReadOnlyDictionary<Led, ArtemisLed>(_ledMap);
UpdateTrigger = new TimerUpdateTrigger {UpdateFrequency = 1.0 / _targetFrameRateSetting.Value};
SetRenderPaused(true);
Surface.RegisterUpdateTrigger(UpdateTrigger);
@@ -132,9 +136,9 @@ namespace Artemis.Core.Services
_texture?.Invalidate();
}
public IReadOnlyCollection<ArtemisDevice> EnabledDevices => _enabledDevices.AsReadOnly();
public IReadOnlyCollection<ArtemisDevice> Devices => _devices.AsReadOnly();
public IReadOnlyDictionary<Led, ArtemisLed> LedMap => new ReadOnlyDictionary<Led, ArtemisLed>(_ledMap);
public IReadOnlyCollection<ArtemisDevice> EnabledDevices { get; }
public IReadOnlyCollection<ArtemisDevice> Devices { get; }
public IReadOnlyDictionary<Led, ArtemisLed> LedMap { get; }
public RGBSurface Surface { get; set; }
public bool IsRenderPaused { get; set; }
@@ -24,6 +24,7 @@ namespace Artemis.Core.Services
_profileService = profileService;
InternalGlobalScripts = new List<GlobalScript>();
GlobalScripts = new(InternalGlobalScripts);
_pluginManagementService.PluginFeatureEnabled += PluginManagementServiceOnPluginFeatureToggled;
_pluginManagementService.PluginFeatureDisabled += PluginManagementServiceOnPluginFeatureToggled;
@@ -80,7 +81,7 @@ namespace Artemis.Core.Services
CreateScriptInstance(profile, scriptConfiguration);
}
public ReadOnlyCollection<GlobalScript> GlobalScripts => InternalGlobalScripts.AsReadOnly();
public ReadOnlyCollection<GlobalScript> GlobalScripts { get; }
public GlobalScript? CreateScriptInstance(ScriptConfiguration scriptConfiguration)
{