Some Lists -> IEnumerable

This commit is contained in:
Bond_009 2019-02-09 01:09:22 +01:00 committed by Bond-009
parent 3e6819c718
commit 7722cb3ffa
2 changed files with 9 additions and 11 deletions

View File

@ -587,7 +587,7 @@ namespace Emby.Server.Implementations.Data
CheckDisposed(); CheckDisposed();
var tuples = new List<Tuple<BaseItem, List<Guid>, BaseItem, string, List<string>>>(); var tuples = new List<(BaseItem, List<Guid>, BaseItem, string, List<string>)>();
foreach (var item in items) foreach (var item in items)
{ {
var ancestorIds = item.SupportsAncestors ? var ancestorIds = item.SupportsAncestors ?
@ -599,7 +599,7 @@ namespace Emby.Server.Implementations.Data
var userdataKey = item.GetUserDataKeys().FirstOrDefault(); var userdataKey = item.GetUserDataKeys().FirstOrDefault();
var inheritedTags = item.GetInheritedTags(); var inheritedTags = item.GetInheritedTags();
tuples.Add(new Tuple<BaseItem, List<Guid>, BaseItem, string, List<string>>(item, ancestorIds, topParent, userdataKey, inheritedTags)); tuples.Add((item, ancestorIds, topParent, userdataKey, inheritedTags));
} }
using (WriteLock.Write()) using (WriteLock.Write())
@ -615,7 +615,7 @@ namespace Emby.Server.Implementations.Data
} }
} }
private void SaveItemsInTranscation(IDatabaseConnection db, List<Tuple<BaseItem, List<Guid>, BaseItem, string, List<string>>> tuples) private void SaveItemsInTranscation(IDatabaseConnection db, IEnumerable<(BaseItem, List<Guid>, BaseItem, string, List<string>)> tuples)
{ {
var statements = PrepareAllSafe(db, new string[] var statements = PrepareAllSafe(db, new string[]
{ {
@ -2094,9 +2094,9 @@ namespace Emby.Server.Implementations.Data
|| query.IsLiked.HasValue; || query.IsLiked.HasValue;
} }
private readonly List<ItemFields> allFields = Enum.GetNames(typeof(ItemFields)) private readonly ItemFields[] _allFields = Enum.GetNames(typeof(ItemFields))
.Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true))
.ToList(); .ToArray();
private string[] GetColumnNamesFromField(ItemFields field) private string[] GetColumnNamesFromField(ItemFields field)
{ {
@ -2305,7 +2305,7 @@ namespace Emby.Server.Implementations.Data
{ {
var list = startColumns.ToList(); var list = startColumns.ToList();
foreach (var field in allFields) foreach (var field in _allFields)
{ {
if (!HasField(query, field)) if (!HasField(query, field))
{ {

View File

@ -396,14 +396,12 @@ namespace MediaBrowser.Api.UserLibrary
public VideoType[] GetVideoTypes() public VideoType[] GetVideoTypes()
{ {
var val = VideoTypes; if (string.IsNullOrEmpty(VideoTypes))
if (string.IsNullOrEmpty(val))
{ {
return new VideoType[] { }; return Array.Empty<VideoType>();
} }
return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray(); return VideoTypes.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray();
} }
/// <summary> /// <summary>