Skip to content

Commit

Permalink
Fixed slow hashtable performance.
Browse files Browse the repository at this point in the history
  • Loading branch information
krisdb2009 committed Mar 5, 2024
1 parent e85cf1d commit 941fdf5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Tikhole.Engine/Committer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,10 @@ public void Dispose()
public class CommitterTrackList : Hashtable
{
public CommitterTrackValue? this[CommitterTrackKey Key] { get => (CommitterTrackValue?)base[Key]; set => base[Key] = value; }
public CommitterTrackList() : base() { }
public void Add(CommitterTrackKey Key, CommitterTrackValue Value)
{
if (!base.Contains(Key)) base.Add(Key, Value);
if (!Contains(Key)) base.Add(Key, Value);
}
public void Remove(CommitterTrackKey Key)
{
Expand All @@ -242,10 +243,15 @@ public bool Contains(CommitterTrackKey Key)
return base.Contains(Key);
}
}

public struct CommitterTrackKey
{
public string List;
public IPAddress Address;
public override int GetHashCode()
{
return HashCode.Combine(List.GetHashCode(), Address.GetHashCode());
}
}
public struct CommitterTrackValue
{
Expand Down

0 comments on commit 941fdf5

Please sign in to comment.