ENet-CSharp
ENet-CSharp copied to clipboard
Peer should impliment IEquatable<T> interface.
Right now if you have peer in a list and call List.Contains(Peer) it will cause GC allocations. Implementing IEquatable<T> on the Peer struct will resolve this issue. See https://medium.com/@semuserable/c-journey-into-struct-equality-comparison-deep-dive-9693f74562f1
Would putting the peers into a Dictionary<uint PeerID, Peer Peer>
solve this? Is there any reason you need to have the Peers in a List like that?
I could do that, but the same problem will happen if you use Dictionary.ContainsValue. Really no reason to not implement IEquatable and I have already done so locally.
I have no objections to this, do you want to do a PR and I'll merge it in?
I'm curious as to why you need to do Dictionary.ContainsValue as suppose to Dictionary.ContainsKey