From c7c69004bf9d9f5edec76550d9b3f7d52e4d871d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=9B=BD=E4=BC=9F?= <366193849@qq.com> Date: Wed, 16 Jun 2021 17:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8List=E5=8F=96=E4=BB=A3HashSet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FastGithub.Scanner/GithubContextCollection.cs | 13 +++++++++---- FastGithub/FastGithub.csproj | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/FastGithub.Scanner/GithubContextCollection.cs b/FastGithub.Scanner/GithubContextCollection.cs index 8108aca..81ecee5 100644 --- a/FastGithub.Scanner/GithubContextCollection.cs +++ b/FastGithub.Scanner/GithubContextCollection.cs @@ -7,13 +7,18 @@ namespace FastGithub.Scanner sealed class GithubContextCollection { private readonly object syncRoot = new(); - private readonly HashSet contextHashSet = new(); + private readonly List contextList = new(); public bool Add(GithubContext context) { lock (this.syncRoot) { - return this.contextHashSet.Add(context); + if (this.contextList.Contains(context)) + { + return false; + } + this.contextList.Add(context); + return true; } } @@ -21,7 +26,7 @@ namespace FastGithub.Scanner { lock (this.syncRoot) { - return this.contextHashSet.ToArray(); + return this.contextList.ToArray(); } } @@ -34,7 +39,7 @@ namespace FastGithub.Scanner { lock (this.syncRoot) { - return this.contextHashSet + return this.contextList .Where(item => item.Available && item.Domain == domain) .OrderByDescending(item => item.Statistics.GetSuccessRate()) .ThenBy(item => item.Statistics.GetAvgElapsed()) diff --git a/FastGithub/FastGithub.csproj b/FastGithub/FastGithub.csproj index ab4f45d..9175207 100644 --- a/FastGithub/FastGithub.csproj +++ b/FastGithub/FastGithub.csproj @@ -5,7 +5,7 @@ enable net5.0;net6.0 true - 1.0.2 + 1.0.0-beta1