Skip to content

Commit

Permalink
Optimize: MotionHandleLinker
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnulusGames committed Jan 16, 2024
1 parent 7b7afad commit a5e49ff
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace LitMotion
Expand All @@ -7,18 +7,20 @@ namespace LitMotion
[AddComponentMenu("")]
internal sealed class MotionHandleLinker : MonoBehaviour
{
readonly List<MotionHandle> handleList = new(8);
readonly MinimumList<MotionHandle> handleList = new(8);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Register(MotionHandle handle)
{
handleList.Add(handle);
}

void OnDestroy()
{
for (int i = 0; i < handleList.Count; i++)
var span = handleList.AsSpan();
for (int i = 0; i < span.Length; i++)
{
var handle = handleList[i];
ref var handle = ref span[i];
if (handle.IsActive()) handle.Cancel();
}
}
Expand Down

0 comments on commit a5e49ff

Please sign in to comment.