mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-04-20 17:14:42 +01:00
More efficient array creation (#11468)
This commit is contained in:
@@ -1130,7 +1130,7 @@ namespace Jellyfin.LiveTv.Channels
|
||||
{
|
||||
if (!item.Tags.Contains("livestream", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
item.Tags = item.Tags.Concat(new[] { "livestream" }).ToArray();
|
||||
item.Tags = [..item.Tags, "livestream"];
|
||||
_logger.LogDebug("Forcing update due to Tags {0}", item.Name);
|
||||
forceUpdate = true;
|
||||
}
|
||||
|
||||
@@ -60,14 +60,13 @@ public class ListingsManager : IListingsManager
|
||||
|
||||
var config = _config.GetLiveTvConfiguration();
|
||||
|
||||
var list = config.ListingProviders.ToList();
|
||||
int index = list.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
|
||||
var list = config.ListingProviders;
|
||||
int index = Array.FindIndex(list, i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (index == -1 || string.IsNullOrWhiteSpace(info.Id))
|
||||
{
|
||||
info.Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
|
||||
list.Add(info);
|
||||
config.ListingProviders = list.ToArray();
|
||||
config.ListingProviders = [..list, info];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -236,13 +235,12 @@ public class ListingsManager : IListingsManager
|
||||
|
||||
if (!string.Equals(tunerChannelNumber, providerChannelNumber, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var list = listingsProviderInfo.ChannelMappings.ToList();
|
||||
list.Add(new NameValuePair
|
||||
var newItem = new NameValuePair
|
||||
{
|
||||
Name = tunerChannelNumber,
|
||||
Value = providerChannelNumber
|
||||
});
|
||||
listingsProviderInfo.ChannelMappings = list.ToArray();
|
||||
};
|
||||
listingsProviderInfo.ChannelMappings = [..listingsProviderInfo.ChannelMappings, newItem];
|
||||
}
|
||||
|
||||
_config.SaveConfiguration("livetv", config);
|
||||
|
||||
@@ -939,7 +939,7 @@ namespace Jellyfin.LiveTv
|
||||
{
|
||||
var internalChannelId = _tvDtoService.GetInternalChannelId(i.Item2.Name, i.Item1.ChannelId);
|
||||
var channel = _libraryManager.GetItemById(internalChannelId);
|
||||
channelName = channel is null ? null : channel.Name;
|
||||
channelName = channel?.Name;
|
||||
}
|
||||
|
||||
return _tvDtoService.GetSeriesTimerInfoDto(i.Item1, i.Item2, channelName);
|
||||
|
||||
@@ -115,11 +115,7 @@ namespace Jellyfin.LiveTv.Timers
|
||||
throw new ArgumentException("item already exists", nameof(item));
|
||||
}
|
||||
|
||||
int oldLen = _items.Length;
|
||||
var newList = new T[oldLen + 1];
|
||||
_items.CopyTo(newList, 0);
|
||||
newList[oldLen] = item;
|
||||
_items = newList;
|
||||
_items = [.._items, item];
|
||||
|
||||
SaveList();
|
||||
}
|
||||
@@ -134,11 +130,7 @@ namespace Jellyfin.LiveTv.Timers
|
||||
int index = Array.FindIndex(_items, i => EqualityComparer(i, item));
|
||||
if (index == -1)
|
||||
{
|
||||
int oldLen = _items.Length;
|
||||
var newList = new T[oldLen + 1];
|
||||
_items.CopyTo(newList, 0);
|
||||
newList[oldLen] = item;
|
||||
_items = newList;
|
||||
_items = [.._items, item];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -76,14 +76,13 @@ public class TunerHostManager : ITunerHostManager
|
||||
|
||||
var config = _config.GetLiveTvConfiguration();
|
||||
|
||||
var list = config.TunerHosts.ToList();
|
||||
var index = list.FindIndex(i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
|
||||
var list = config.TunerHosts;
|
||||
var index = Array.FindIndex(list, i => string.Equals(i.Id, info.Id, StringComparison.OrdinalIgnoreCase));
|
||||
|
||||
if (index == -1 || string.IsNullOrWhiteSpace(info.Id))
|
||||
{
|
||||
info.Id = Guid.NewGuid().ToString("N", CultureInfo.InvariantCulture);
|
||||
list.Add(info);
|
||||
config.TunerHosts = list.ToArray();
|
||||
config.TunerHosts = [..list, info];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user