diff options
| author | Bond-009 <bond.009@outlook.com> | 2024-04-30 21:32:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-30 13:32:59 -0600 |
| commit | 3feb3f81bfe848aa829e7c129bee3cd060c23c05 (patch) | |
| tree | c247db8e30d1cc52bc6735d45d86eff8955ee7e9 /MediaBrowser.Controller/Entities/BaseItem.cs | |
| parent | 5dc6bb4910cfdc7f40ad83d647172d743e6e0595 (diff) | |
More efficient array creation (#11468)
Diffstat (limited to 'MediaBrowser.Controller/Entities/BaseItem.cs')
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 6c9097689..22793206e 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -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) |
