mirror of
https://github.com/JustArchiNET/ArchiSteamFarm.git
synced 2026-01-01 06:00:46 +00:00
Optimize updating of server list
We can compare new endpoints firstly, to save Save() call if they're equal values-wise.
This commit is contained in:
@@ -40,17 +40,19 @@ namespace ArchiSteamFarm {
|
||||
|
||||
public Task<IEnumerable<IPEndPoint>> FetchServerListAsync() => Task.FromResult<IEnumerable<IPEndPoint>>(Servers);
|
||||
|
||||
public Task UpdateServerListAsync(IEnumerable<IPEndPoint> endpoints) {
|
||||
if (endpoints == null) {
|
||||
Logging.LogNullError(nameof(endpoints));
|
||||
public Task UpdateServerListAsync(IEnumerable<IPEndPoint> endPoints) {
|
||||
if (endPoints == null) {
|
||||
Logging.LogNullError(nameof(endPoints));
|
||||
return Task.Delay(0);
|
||||
}
|
||||
|
||||
Servers.Clear();
|
||||
foreach (IPEndPoint endpoint in endpoints) {
|
||||
Servers.Add(endpoint);
|
||||
HashSet<IPEndPoint> newEndPoints = new HashSet<IPEndPoint>(endPoints);
|
||||
if (Servers.SetEquals(newEndPoints)) {
|
||||
return Task.Delay(0);
|
||||
}
|
||||
|
||||
Servers = newEndPoints;
|
||||
|
||||
ServerListUpdated(this, EventArgs.Empty);
|
||||
|
||||
return Task.Delay(0);
|
||||
|
||||
Reference in New Issue
Block a user