mirror of
https://github.com/Ryujinx/Opentk.git
synced 2025-06-19 20:57:49 +00:00
[Common] Avoid GC in DeviceCollection
`DeviceCollection.GetEnumerator()` now returns a struct IEnumerable<T> directly to avoid boxing. Additionally, we can now use `DeviceCollection[int]` as a shortcut to `FromIndex(int)`.
This commit is contained in:
parent
2b3a4c578a
commit
747d86bafb
|
@ -46,7 +46,7 @@ namespace OpenTK.Platform
|
||||||
|
|
||||||
#region IEnumerable<T> Members
|
#region IEnumerable<T> Members
|
||||||
|
|
||||||
public IEnumerator<T> GetEnumerator()
|
IEnumerator<T> IEnumerable<T>.GetEnumerator()
|
||||||
{
|
{
|
||||||
return Devices.GetEnumerator();
|
return Devices.GetEnumerator();
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,17 @@ namespace OpenTK.Platform
|
||||||
|
|
||||||
#region Public Members
|
#region Public Members
|
||||||
|
|
||||||
|
// This avoids boxing when using foreach loops
|
||||||
|
public List<T>.Enumerator GetEnumerator()
|
||||||
|
{
|
||||||
|
return Devices.GetEnumerator();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T this[int index]
|
||||||
|
{
|
||||||
|
get { return FromIndex(index); }
|
||||||
|
}
|
||||||
|
|
||||||
/// \internal
|
/// \internal
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds or replaces a device based on its hardware id.
|
/// Adds or replaces a device based on its hardware id.
|
||||||
|
|
Loading…
Reference in a new issue