mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-05 07:18:47 +01:00
More efficient array creation (#11468)
This commit is contained in:
@@ -1779,14 +1779,11 @@ namespace MediaBrowser.Controller.Entities
|
||||
int curLen = current.Length;
|
||||
if (curLen == 0)
|
||||
{
|
||||
Studios = new[] { name };
|
||||
Studios = [name];
|
||||
}
|
||||
else
|
||||
{
|
||||
var newArr = new string[curLen + 1];
|
||||
current.CopyTo(newArr, 0);
|
||||
newArr[curLen] = name;
|
||||
Studios = newArr;
|
||||
Studios = [..current, name];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1808,9 +1805,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
var genres = Genres;
|
||||
if (!genres.Contains(name, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var list = genres.ToList();
|
||||
list.Add(name);
|
||||
Genres = list.ToArray();
|
||||
Genres = [..genres, name];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1980,12 +1975,7 @@ namespace MediaBrowser.Controller.Entities
|
||||
|
||||
public void AddImage(ItemImageInfo image)
|
||||
{
|
||||
var current = ImageInfos;
|
||||
var currentCount = current.Length;
|
||||
var newArr = new ItemImageInfo[currentCount + 1];
|
||||
current.CopyTo(newArr, 0);
|
||||
newArr[currentCount] = image;
|
||||
ImageInfos = newArr;
|
||||
ImageInfos = [..ImageInfos, image];
|
||||
}
|
||||
|
||||
public virtual Task UpdateToRepositoryAsync(ItemUpdateType updateReason, CancellationToken cancellationToken)
|
||||
|
||||
Reference in New Issue
Block a user