Skip to content

Instantly share code, notes, and snippets.

@takazerker
Created July 13, 2023 15:18
Show Gist options
  • Save takazerker/29ead5e4d35ab483bf33e972492df608 to your computer and use it in GitHub Desktop.
Save takazerker/29ead5e4d35ab483bf33e972492df608 to your computer and use it in GitHub Desktop.
using System.Collections.Generic;
using UnityEngine.Pool;
public struct PooledListScope<T> : System.IDisposable
{
List<T> m_List;
public static PooledListScope<T> Get(out List<T> list)
{
list = ListPool<T>.Get();
return new PooledListScope<T>() { m_List = list };
}
public void Dispose()
{
ListPool<T>.Release(m_List);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment