aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/plugin
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2023-05-29 12:38:01 +0800
committershedaniel <daniel@shedaniel.me>2023-05-29 12:38:24 +0800
commit4b8675eda54b16c5b5f4a03eed9eb31ea5cadd4f (patch)
tree78dc2bef419ecaf493480335fdf58c2ff4b58a4e /runtime/src/main/java/me/shedaniel/rei/plugin
parent50833c4668b5e7688d172767659eb8fee10f77e6 (diff)
downloadRoughlyEnoughItems-4b8675eda54b16c5b5f4a03eed9eb31ea5cadd4f.tar.gz
RoughlyEnoughItems-4b8675eda54b16c5b5f4a03eed9eb31ea5cadd4f.tar.bz2
RoughlyEnoughItems-4b8675eda54b16c5b5f4a03eed9eb31ea5cadd4f.zip
Improve search performance
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/plugin')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchFilterPrepareWatcher.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchFilterPrepareWatcher.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchFilterPrepareWatcher.java
index ea1db5d72..f2acdcc80 100644
--- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchFilterPrepareWatcher.java
+++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/SearchFilterPrepareWatcher.java
@@ -24,12 +24,12 @@
package me.shedaniel.rei.plugin.client.runtime;
import com.google.common.collect.ImmutableList;
-import it.unimi.dsi.fastutil.ints.IntIntPair;
import me.shedaniel.math.Color;
import me.shedaniel.math.Point;
import me.shedaniel.rei.api.client.gui.widgets.Tooltip;
import me.shedaniel.rei.impl.client.gui.hints.HintProvider;
import me.shedaniel.rei.impl.client.search.argument.Argument;
+import me.shedaniel.rei.impl.client.search.argument.ArgumentCache;
import net.minecraft.Util;
import net.minecraft.network.chat.Component;
import org.apache.commons.lang3.ArrayUtils;
@@ -45,14 +45,15 @@ public class SearchFilterPrepareWatcher implements HintProvider {
public List<Component> provide() {
lastProcess = null;
try {
- if (Argument.prepareStage != null && Argument.currentStages != null && Argument.prepareStacks != null && Argument.prepareStacks.size() > 100
- && Argument.prepareStart != null) {
- if (Util.getEpochMillis() - Argument.prepareStart < 100) return Collections.emptyList();
- int prepareStageCurrent = Argument.prepareStage.firstInt();
- int prepareStageTotal = Argument.prepareStage.secondInt();
- IntIntPair currentStage = ArrayUtils.get(Argument.currentStages, prepareStageCurrent - 1);
- int currentStageCurrent = currentStage == null ? 0 : currentStage.firstInt();
- int currentStageTotal = currentStage == null ? 0 : currentStage.secondInt();
+ ArgumentCache cache = Argument.cache;
+ if (cache.currentStep != null && cache.prepareStacks != null && cache.prepareStacks.size() > 100
+ && cache.prepareStart != null) {
+ if (Util.getEpochMillis() - cache.prepareStart < 100) return Collections.emptyList();
+ int prepareStageCurrent = cache.currentStep.step;
+ int prepareStageTotal = cache.currentStep.totalSteps;
+ ArgumentCache.CurrentStep.Step currentStage = ArrayUtils.get(cache.currentStep.steps, prepareStageCurrent - 1);
+ int currentStageCurrent = currentStage == null ? 0 : currentStage.stacks;
+ int currentStageTotal = currentStage == null ? 0 : currentStage.totalStacks;
double prepareStageProgress = prepareStageTotal == 0 ? 0 : prepareStageCurrent / (double) prepareStageTotal;
double currentStageProgress = currentStageTotal == 0 ? 0 : currentStageCurrent / (double) currentStageTotal;
double lastProcess = prepareStageTotal == 0 ? 0 : Math.max(0, prepareStageProgress - (1 - currentStageProgress) / prepareStageTotal);