Closed Gieted closed 6 months ago
Hi, thanks so much for this pull request! Please fix any compile issues and I can merge :)
Implementing a version of this myself. Thanks for the pull request, though! ❤️
@Ellpeck Sorry for not responding, I was pretty busy last week.
I've looked into your changes on master and have 2 suggestions:
Here I've used LinkedHashMap instead of HashMap, because regular HashMap might scrable order of elements, while LinkedHashMap keeps the order of addition. Not sure if it's relevant to your implementation.
It depends on specific implementation of Map, but putIfAbsent() might actually be faster than containsKey() (on the other hand, you are skipping an unnecessary object creation, so it isn't a clear-cut which one will be actually faster in practice).
Hm, yea, I meant to also be using the linked hash map but I guess I must've forgot about it halfway through. It seemed to work from my testing, but I know that's largely because element order is preserved most of the time, just not guaranteed to be. Thanks for flagging that up!
I've noticed that my server is having low tps problem, despite good hardware. After some debugging, I've concluded that lag is caused by PipeNetwork.getOrderedNetworkItems() function.
A simple change could be made to improve its performance and fix the lag.