Fixed: Avoid zero-length array memory allocations

This commit is contained in:
Qstick
2020-10-02 14:29:25 -04:00
parent 295b975046
commit 4ec71538b9
34 changed files with 64 additions and 55 deletions

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Text.Json;
@@ -49,8 +50,8 @@ namespace NzbDrone.Core.Datastore.Migration
Password = settings.Password,
From = settings.From,
To = new string[] { settings.To },
CC = new string[] { },
Bcc = new string[] { }
CC = Array.Empty<string>(),
Bcc = Array.Empty<string>()
};
corrected.Add(new ProviderDefinition166

View File

@@ -349,7 +349,7 @@ namespace NzbDrone.Core.Download.Clients.Deluge
{
if (result.Torrents == null)
{
return new DelugeTorrent[0];
return Array.Empty<DelugeTorrent>();
}
return result.Torrents.Values.ToArray();

View File

@@ -106,7 +106,7 @@ namespace NzbDrone.Core.Download.Clients.Hadouken
{
if (torrentsRaw == null)
{
return new HadoukenTorrent[0];
return Array.Empty<HadoukenTorrent>();
}
var torrents = new List<HadoukenTorrent>();

View File

@@ -17,7 +17,7 @@ namespace NzbDrone.Core.Download.TrackedDownloads
public TrackedDownload()
{
StatusMessages = new TrackedDownloadStatusMessage[] { };
StatusMessages = System.Array.Empty<TrackedDownloadStatusMessage>();
}
public void Warn(string message, params object[] args)

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Annotations;
@@ -23,8 +24,8 @@ namespace NzbDrone.Core.ImportLists.Radarr
{
BaseUrl = "";
ApiKey = "";
ProfileIds = new int[] { };
TagIds = new int[] { };
ProfileIds = Array.Empty<int>();
TagIds = Array.Empty<int>();
}
[FieldDefinition(0, Label = "Full URL", HelpText = "URL, including port, of the Radarr V3 instance to import from")]

View File

@@ -28,8 +28,8 @@ namespace NzbDrone.Core.Indexers.HDBits
MinimumSeeders = IndexerDefaults.MINIMUM_SEEDERS;
Categories = new int[] { (int)HdBitsCategory.Movie };
Codecs = new int[0];
Mediums = new int[0];
Codecs = System.Array.Empty<int>();
Mediums = System.Array.Empty<int>();
MultiLanguages = new List<int>();
RequiredFlags = new List<int>();
}

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using FluentValidation;
@@ -35,9 +36,9 @@ namespace NzbDrone.Core.Notifications.Email
Port = 587;
Ssl = true;
To = new string[] { };
CC = new string[] { };
Bcc = new string[] { };
To = Array.Empty<string>();
CC = Array.Empty<string>();
Bcc = Array.Empty<string>();
}
[FieldDefinition(0, Label = "Server", HelpText = "Hostname or IP of Email server")]

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Annotations;
@@ -20,8 +21,8 @@ namespace NzbDrone.Core.Notifications.PushBullet
public PushBulletSettings()
{
DeviceIds = new string[] { };
ChannelTags = new string[] { };
DeviceIds = Array.Empty<string>();
ChannelTags = Array.Empty<string>();
}
[FieldDefinition(0, Label = "Access Token", HelpLink = "https://www.pushbullet.com/#settings/account")]

View File

@@ -23,7 +23,7 @@ namespace NzbDrone.Core.Notifications.Pushover
public PushoverSettings()
{
Priority = 0;
Devices = new string[] { };
Devices = System.Array.Empty<string>();
}
//TODO: Get Pushover to change our app name (or create a new app) when we have a new logo

View File

@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using FluentValidation;
using NzbDrone.Core.Annotations;
@@ -24,7 +25,7 @@ namespace NzbDrone.Core.Notifications.SendGrid
public SendGridSettings()
{
BaseUrl = "https://api.sendgrid.com/v3/";
Recipients = new string[] { };
Recipients = Array.Empty<string>();
}
public string BaseUrl { get; set; }