mirror of
https://github.com/Radarr/Radarr
synced 2026-01-26 09:23:39 +01:00
perf: replace List.Contains() with HashSet for O(1) lookups (#92)
- ReleaseSearchService: wrap wantedLanguages in HashSet<Language> - FileNameBuilder: convert splitFilter array to HashSet<string> - NewznabCategoryFieldOptionsConverter: use HashSet<int> for category filters Addresses Issue #35 Co-authored-by: admin <admin@ardentleatherworks.com>
This commit is contained in:
parent
f4f7253165
commit
739a672637
3 changed files with 6 additions and 5 deletions
|
|
@ -8,6 +8,7 @@
|
|||
using NzbDrone.Core.DecisionEngine;
|
||||
using NzbDrone.Core.Indexers;
|
||||
using NzbDrone.Core.IndexerSearch.Definitions;
|
||||
using NzbDrone.Core.Languages;
|
||||
using NzbDrone.Core.Movies;
|
||||
using NzbDrone.Core.Movies.Translations;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
|
|
@ -75,7 +76,7 @@ private TSpec Get<TSpec>(Movie movie, bool userInvokedSearch, bool interactiveSe
|
|||
InteractiveSearch = interactiveSearch
|
||||
};
|
||||
|
||||
var wantedLanguages = _qualityProfileService.GetAcceptableLanguages(movie.QualityProfileId);
|
||||
var wantedLanguages = new HashSet<Language>(_qualityProfileService.GetAcceptableLanguages(movie.QualityProfileId));
|
||||
var translations = _movieTranslationService.GetAllTranslationsForMovieMetadata(movie.MovieMetadataId);
|
||||
|
||||
var queryTranslations = new List<string>
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ public static class NewznabCategoryFieldOptionsConverter
|
|||
public static List<FieldSelectOption<int>> GetFieldSelectOptions(List<NewznabCategory> categories)
|
||||
{
|
||||
// Categories not relevant for Radarr
|
||||
var ignoreCategories = new[] { 1000, 3000, 4000, 6000, 7000 };
|
||||
var ignoreCategories = new HashSet<int> { 1000, 3000, 4000, 6000, 7000 };
|
||||
|
||||
// And maybe relevant for specific users
|
||||
var unimportantCategories = new[] { 0, 5000 };
|
||||
var unimportantCategories = new HashSet<int> { 0, 5000 };
|
||||
|
||||
var result = new List<FieldSelectOption<int>>();
|
||||
|
||||
|
|
|
|||
|
|
@ -451,12 +451,12 @@ private static string GetCustomFormatsToken(List<CustomFormat> customFormats, st
|
|||
{
|
||||
if (filter.StartsWith("-"))
|
||||
{
|
||||
var splitFilter = filter.Substring(1).Split(',');
|
||||
var splitFilter = new HashSet<string>(filter.Substring(1).Split(','));
|
||||
filteredTokens = tokens.Where(c => !splitFilter.Contains(c.Name)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var splitFilter = filter.Split(',');
|
||||
var splitFilter = new HashSet<string>(filter.Split(','));
|
||||
filteredTokens = tokens.Where(c => splitFilter.Contains(c.Name)).ToList();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue