aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils
diff options
context:
space:
mode:
authorhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-03 03:24:50 +0100
committerhannibal2 <24389977+hannibal00212@users.noreply.github.com>2023-12-03 03:24:50 +0100
commitd4ee6c0e61a2543a654ade7be19b0effe95fb8d1 (patch)
tree2ff9e1c7d7e913cfa6e01c14ff93e2fe1b712aa0 /src/main/java/at/hannibal2/skyhanni/utils
parent6e36d679df0444f19a65c6c81dd26e5b344a2cd7 (diff)
downloadskyhanni-d4ee6c0e61a2543a654ade7be19b0effe95fb8d1.tar.gz
skyhanni-d4ee6c0e61a2543a654ade7be19b0effe95fb8d1.tar.bz2
skyhanni-d4ee6c0e61a2543a654ade7be19b0effe95fb8d1.zip
Increased performance and decreased ram usage.
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
index 007d9f1d5..7965a2ded 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/NEUItems.kt
@@ -17,6 +17,7 @@ import io.github.moulberry.notenoughupdates.NotEnoughUpdates
import io.github.moulberry.notenoughupdates.overlays.AuctionSearchOverlay
import io.github.moulberry.notenoughupdates.overlays.BazaarSearchOverlay
import io.github.moulberry.notenoughupdates.recipes.CraftingRecipe
+import io.github.moulberry.notenoughupdates.recipes.Ingredient
import io.github.moulberry.notenoughupdates.recipes.NeuRecipe
import io.github.moulberry.notenoughupdates.util.ItemResolutionQuery
import io.github.moulberry.notenoughupdates.util.Utils
@@ -34,6 +35,7 @@ object NEUItems {
private val itemNameCache = mutableMapOf<String, NEUInternalName>() // item name -> internal name
private val multiplierCache = mutableMapOf<String, Pair<String, Int>>()
private val recipesCache = mutableMapOf<String, Set<NeuRecipe>>()
+ private val ingredientsCache = mutableMapOf<NeuRecipe, Set<Ingredient>>()
private val enchantmentNamePattern = Pattern.compile("^(?<format>(?:§.)+)(?<name>[^§]+) (?<level>[IVXL]+)$")
var allItemsCache = mapOf<String, NEUInternalName>() // item name -> internal name
var allInternalNames = mutableListOf<NEUInternalName>()
@@ -244,7 +246,7 @@ object NEUItems {
if (recipe !is CraftingRecipe) continue
val map = mutableMapOf<String, Int>()
- for (ingredient in recipe.ingredients) {
+ for (ingredient in recipe.getCachedIngredients()) {
val count = ingredient.count.toInt()
var internalItemId = ingredient.internalItemId
// ignore cactus green
@@ -297,6 +299,8 @@ object NEUItems {
return recipes
}
+ fun NeuRecipe.getCachedIngredients() = ingredientsCache.getOrPut(this) { ingredients }
+
fun neuHasFocus(): Boolean {
if (AuctionSearchOverlay.shouldReplace()) return true
if (BazaarSearchOverlay.shouldReplace()) return true