Use an identity map to store Snapshotable

Signed-off-by: TheMode <themode@outlook.fr>
This commit is contained in:
TheMode 2022-05-03 18:55:41 +02:00
parent 1384bc0c18
commit 0dc7f52a50
2 changed files with 4 additions and 5 deletions

View File

@ -2,16 +2,13 @@
package net.minestom.server.snapshot;
import it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
final class SnapshotUpdaterImpl implements SnapshotUpdater {
private final Object2ObjectOpenHashMap<Snapshotable, AtomicReference<Snapshot>> referenceMap = new Object2ObjectOpenHashMap<>();
private final Map<Snapshotable, AtomicReference<Snapshot>> referenceMap = new IdentityHashMap<>();
private List<Entry> queue = new ArrayList<>();
static <T extends Snapshot> @NotNull T update(@NotNull Snapshotable snapshotable) {

View File

@ -5,6 +5,8 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents an object which is regularly saved into a snapshot.
* <p>
* Implementations must be identity-based.
*/
@ApiStatus.Experimental
public interface Snapshotable {