Revert "Optimize iteration in reference chunk loader"
Shiroha CI / build (push) Canceled after 0s
Shiroha CI / Event File (push) Canceled after 0s

This commit is contained in:
2026-08-22 23:20:22 +08:00
parent 6f7ba53119
commit 6fdd8eee4a
@@ -218,23 +218,11 @@ public class ReferenceCountingChunkLoader {
final ReferenceCountData[] toRemoveTicket = new ReferenceCountData[1];
final it.unimi.dsi.fastutil.longs.LongIterator sectionsIterator = currentRegion.getOwnedSectionsUnsynchronised();
while (sectionsIterator.hasNext()) {
final long sectionKey = sectionsIterator.nextLong();
final int sectionX = CoordinateUtils.getChunkX(sectionKey);
final int sectionZ = CoordinateUtils.getChunkZ(sectionKey);
for (ConcurrentChainedLong2ReferenceHashTable.TableEntry<ReferenceCountData> counterEntry : this.referenceCounters.entrySet()) {
final long coord = counterEntry.getKey();
final ReferenceCountData counterData = counterEntry.getValue();
final int chunkX = sectionX << this.world.regioniser.sectionChunkShift;
final int chunkZ = sectionZ << this.world.regioniser.sectionChunkShift;
final long coord = CoordinateUtils.getChunkKey(chunkX, chunkZ);
final ReferenceCountData counterData = this.referenceCounters.get(coord);
// removed
if (counterData == null) {
continue;
}
// do ttl
if (currentRegion == this.world.regioniser.getRegionAtUnsynchronised(CoordinateUtils.getChunkX(coord), CoordinateUtils.getChunkZ(coord))) {
long curr = counterData.referenceTTL.get();
if (curr == (curr = counterData.referenceTTL.compareAndExchange(curr, curr - 1))) {
if (counterData.referenceCount.get() != 0L) {
@@ -262,6 +250,7 @@ public class ReferenceCountingChunkLoader {
}
}
}
}
private static final class ReferenceCountData {