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

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Artemis.Core;
using Artemis.Core.Modules;
@@ -26,10 +27,13 @@ namespace Artemis.UI.Shared.Services
_kernel = kernel;
_registeredDataModelEditors = new List<DataModelVisualizationRegistration>();
_registeredDataModelDisplays = new List<DataModelVisualizationRegistration>();
RegisteredDataModelEditors = new ReadOnlyCollection<DataModelVisualizationRegistration>(_registeredDataModelEditors);
RegisteredDataModelDisplays = new ReadOnlyCollection<DataModelVisualizationRegistration>(_registeredDataModelDisplays);
}
public IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelEditors => _registeredDataModelEditors.AsReadOnly();
public IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelDisplays => _registeredDataModelDisplays.AsReadOnly();
public IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelEditors { get; }
public IReadOnlyCollection<DataModelVisualizationRegistration> RegisteredDataModelDisplays { get; }
public DataModelPropertiesViewModel GetMainDataModelVisualization()
{
@@ -39,6 +39,8 @@ namespace Artemis.UI.Shared.Services
_rgbService = rgbService;
_moduleService = moduleService;
_registeredPropertyEditors = new List<PropertyInputRegistration>();
RegisteredPropertyEditors = new(_registeredPropertyEditors);
coreService.FrameRendered += CoreServiceOnFrameRendered;
PixelsPerSecond = 100;
}
@@ -103,7 +105,7 @@ namespace Artemis.UI.Shared.Services
}
}
public ReadOnlyCollection<PropertyInputRegistration> RegisteredPropertyEditors => _registeredPropertyEditors.AsReadOnly();
public ReadOnlyCollection<PropertyInputRegistration> RegisteredPropertyEditors { get; }
public bool Playing { get; set; }