Functional Storage

Functional Storage

24M Downloads

Minor performance degradation from getSlots method

MichaelHillcox opened this issue · 0 comments

commented

Version

functionalstorage-1.18.2-0.0.14.jar

Spark report

https://spark.lucko.me/Z3jImmrwpR

Info

From what I can tell this method is causing some unneeded strain on servers when a mod queries the slots of the inventory a lot which is relatively common. It looks like you could cache this relatively simply by adding the slots count into the rebuild method and hold it on the controller. I’ve not had time to test as I was going to make a PR.

        return getDrawers().getHandlers().stream()
            .filter(iItemHandler -> !(iItemHandler instanceof ControllerInventoryHandler))
            .map(IItemHandler::getSlots)
            .mapToInt(Integer::intValue)
            .sum();

Hope that’s helpful :)