1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 00:47:24 +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> public class EmptyRealmSet<T> : IRealmCollection<T>
{ {
private static List<T> emptySet => new List<T>(); private IList<T> emptySet => Array.Empty<T>();
public IEnumerator<T> GetEnumerator()
{
return emptySet.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable)emptySet).GetEnumerator();
}
public IEnumerator<T> GetEnumerator() => emptySet.GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => emptySet.GetEnumerator();
public int Count => emptySet.Count; public int Count => emptySet.Count;
public T this[int index] => emptySet[index]; 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 public event NotifyCollectionChangedEventHandler? CollectionChanged
{ {
@ -43,32 +36,11 @@ namespace osu.Game.Database
remove => throw new NotImplementedException(); remove => throw new NotImplementedException();
} }
public int IndexOf(object item) public IRealmCollection<T> Freeze() => throw new NotImplementedException();
{ public IDisposable SubscribeForNotifications(NotificationCallbackDelegate<T> callback) => throw new NotImplementedException();
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 bool IsValid => throw new NotImplementedException(); public bool IsValid => throw new NotImplementedException();
public Realm Realm => throw new NotImplementedException(); public Realm Realm => throw new NotImplementedException();
public ObjectSchema ObjectSchema => throw new NotImplementedException(); public ObjectSchema ObjectSchema => throw new NotImplementedException();
public bool IsFrozen => throw new NotImplementedException(); public bool IsFrozen => throw new NotImplementedException();
} }
} }