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

@@ -44,6 +44,7 @@ namespace Artemis.Core
_baseValue = default!;
_keyframes = new List<LayerPropertyKeyframe<T>>();
Keyframes = new(_keyframes);
}
/// <summary>
@@ -337,7 +338,7 @@ namespace Artemis.Core
#region Keyframes
private bool _keyframesEnabled;
private List<LayerPropertyKeyframe<T>> _keyframes;
private readonly List<LayerPropertyKeyframe<T>> _keyframes;
/// <summary>
/// Gets whether keyframes are supported on this type of property
@@ -363,7 +364,7 @@ namespace Artemis.Core
/// <summary>
/// Gets a read-only list of all the keyframes on this layer property
/// </summary>
public ReadOnlyCollection<LayerPropertyKeyframe<T>> Keyframes => _keyframes.AsReadOnly();
public ReadOnlyCollection<LayerPropertyKeyframe<T>> Keyframes { get; }
/// <summary>
/// Gets the current keyframe in the timeline according to the current progress
@@ -436,7 +437,7 @@ namespace Artemis.Core
/// </summary>
internal void SortKeyframes()
{
_keyframes = _keyframes.OrderBy(k => k.Position).ToList();
_keyframes.Sort((a, b) => a.Position.CompareTo(b.Position));
}
private void UpdateKeyframes(Timeline timeline)