BentoBoxWorld / Greenhouses

BentoBox Add-on to enable personal biomes in a glass greenhouse
Eclipse Public License 2.0
13 stars 9 forks source link

Optimize convertBlocks and convertBlock methods by reducing the amoun… #78

Closed Rossterd closed 3 years ago

Rossterd commented 3 years ago

…t of code inside of the loops, and doing cheap checks before more expensive ones.

Using large (150x150x200) greenhouses has been causing ~2s ticks when the plugin runs the block conversion. While some lag is a given when manipulating this many blocks, rewriting the methods to do as little as possible inside of the loops has allowed me to bring the block conversion ticks down to ~300ms.

As far as I can tell most of the lag came from running gh.getBiomeRecipe() for every non air block inside of the greenhouse and also some mysterious lag from the convertBlock method even if conversionBlocks.get(bType) returns an empty collection. I suspect it's because it has to create the collection?

tastybento commented 3 years ago

Thank you for the PR!