Optimize the Spire

If you liked this item, please rate it up on Steam Workshop page.

Author: (Gk) Erasels

Last revision: 16 Jun, 2022 at 19:09 UTC

File size: 31.74 KB

On Steam Workshop

Description:

Essentially, this mod’s goal is to make Slay the Spire run smoother when you’re running it with mods. These changes affect vanilla spire as well, but their effect will be negligible in that case

For that, I’ve implemented a few somewhat invasive changes, which I’ll explain below.

These changes don’t affect RAM usage, so if you’re having problems because of that, this mod will do nothing for you.

Boring techinical stuff:
1) I’ve optimized hasRelic and getRelic to be O(1) from the theoretical worst-case of O(n). I did this by creating a hashmap that stores information on which relics are where in the relics arraylist and making those methods use the hasmap to skip list iteration.

In practice, this change has saved me 3 billion unneeded list-iterations during a heavily modded playthrough. The majority of which happen when booting up the game.

2) A more noticeable change, is that I intercept the standard, non-essential loggers and skip their outputs. Crash information is retained and this can be toggled in the mod config menu.

Printing to the console is a very wasteful process, skipping most of the bloat makes things like starting a new run or the game smoother and on lower-end PCs, maybe even the combat.
However, my approach isn’t perfect, using sysout or registering your logger in a non-standard way will circumvent this measure but the majority is enough in this case.

3) When looking at the master deck and using the sort function, the game orders the cards every frame (30-60 times a second). I’ve changed this so that it only sorts the cards when needed.

In practice, this change will most likely never matter unless you’re running a 1000+ card deck but every little bit helps.

4) If you look at upgraded cards in the compendium, all the cards you’re seeing are duplicated and their copies upgraded every frame. Instead I save all the upgraded variants whenever they become relevant and make the compendium just render those instead. I also clean the Hashmap i store them in so that there’s no unneccessary RAM usage going on.

This change may actually be quite impactful for people with issues in the compendium.

It’s debatable how much these changes help, but it doesn’t hurt to give it a try.

Download
Required items:

Click the title to search on this site.


BaseModSteam Workshop
ModTheSpireSteam Workshop