BeardedManStudios / ForgeNetworkingRemastered

See various forks, also please join the Forge Community fork of Forge Alloy! -> https://github.com/ForgeAlloyCommunity/ForgeAlloy
https://twitter.com/FarrisFaulds
Apache License 2.0
1.49k stars 306 forks source link

Fixing pooling performance #353

Closed BrentFarris closed 4 years ago

BrentFarris commented 4 years ago

List.RemoveAt(0) has the worst remove performance from a list since it removes back to front (see MS documentation). Utilizing a queue instead for performance and clarity. Also there is no need to keep track of the messages that are in use, they will return when they return.

List.RemoveAt documentation note:

This method is an O(n) operation, where n is (Count - index)

BrentFarris commented 4 years ago

I see that changes were also made in the csproj files, should they be a part of this PR?

@mcguinnessdr hmm, looks like Unity upgraded the .csproj to the same unity version randomly. Thought I would commit them since there weren't any other unity specific changes other than those. I can give it another check though

mcguinnessdr commented 4 years ago

I see that changes were also made in the csproj files, should they be a part of this PR?

@mcguinnessdr hmm, looks like Unity upgraded the .csproj to the same unity version randomly. Thought I would commit them since there weren't any other unity specific changes other than those. I can give it another check though

As long as they're not going to cause problems opening in a different version of Unity it should be fine.