LinkedHashSet instead of ObjectLinkedOpenHashSet for update performance

because LinkedHashSet uses linked list, while ObjectLinkedOpenHashSet use sequential array of keys
This commit is contained in:
DBotThePony 2025-01-19 20:56:32 +07:00
parent 20b3fe78ba
commit 9579bc6a0c
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -1,8 +1,5 @@
package ru.dbotthepony.mc.otm.block.entity.cable
import it.unimi.dsi.fastutil.ints.IntLists
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap
import it.unimi.dsi.fastutil.objects.ReferenceArraySet
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet
@ -19,6 +16,7 @@ import ru.dbotthepony.mc.otm.onceServer
import java.util.*
import kotlin.collections.ArrayList
import kotlin.collections.HashSet
import kotlin.collections.LinkedHashSet
import kotlin.math.ln
class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableGraph>() {
@ -69,7 +67,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
}
class SegmentPath(private val a: BlockPos, private val b: BlockPos) {
val segments = ObjectLinkedOpenHashSet<Segment>()
val segments = LinkedHashSet<Segment>()
private var shortCircuit = false
private var lastTickTransfers = 0
private var lastTick = 0
@ -134,7 +132,7 @@ class EnergyCableGraph : GraphNodeList<EnergyCableBlockEntity.Node, EnergyCableG
nodes.add(node)
}
private val nodes = ObjectLinkedOpenHashSet<EnergyCableBlockEntity.Node>()
private val nodes = LinkedHashSet<EnergyCableBlockEntity.Node>()
private val paths = ReferenceOpenHashSet<SegmentPath>()
operator fun contains(node: EnergyCableBlockEntity.Node): Boolean {