1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Use Array.Empty instead of constructed list

This commit is contained in:
Dean Herbert 2022-01-23 23:17:33 +09:00
parent 249f0f9697
commit deb1670862

View File

@ -15,21 +15,14 @@ namespace osu.Game.Database
{
public class EmptyRealmSet<T> : IRealmCollection<T>
{
private static List<T> emptySet => new List<T>();
public IEnumerator<T> GetEnumerator()
{
return emptySet.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)emptySet).GetEnumerator();
}
private IList<T> emptySet => Array.Empty<T>();
public IEnumerator<T> GetEnumerator() => emptySet.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => emptySet.GetEnumerator();
public int Count => emptySet.Count;
public T this[int index] => emptySet[index];
public int IndexOf(object item) => emptySet.IndexOf((T)item);
public bool Contains(object item) => emptySet.Contains((T)item);
public event NotifyCollectionChangedEventHandler? CollectionChanged
{
@ -43,32 +36,11 @@ namespace osu.Game.Database
remove => throw new NotImplementedException();
}
public int IndexOf(object item)
{
return emptySet.IndexOf((T)item);
}
public bool Contains(object item)
{
return emptySet.Contains((T)item);
}
public IRealmCollection<T> Freeze()
{
throw new NotImplementedException();
}
public IDisposable SubscribeForNotifications(NotificationCallbackDelegate<T> callback)
{
throw new NotImplementedException();
}
public IRealmCollection<T> Freeze() => throw new NotImplementedException();
public IDisposable SubscribeForNotifications(NotificationCallbackDelegate<T> callback) => throw new NotImplementedException();
public bool IsValid => throw new NotImplementedException();
public Realm Realm => throw new NotImplementedException();
public ObjectSchema ObjectSchema => throw new NotImplementedException();
public bool IsFrozen => throw new NotImplementedException();
}
}