mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
Cache registry collections
This commit is contained in:
parent
aa1fc186f0
commit
bf48154aee
@ -66,6 +66,7 @@ public final class Registry {
|
|||||||
private final Map<String, T> namespaceMap = new HashMap<>();
|
private final Map<String, T> namespaceMap = new HashMap<>();
|
||||||
// id -> registry data
|
// id -> registry data
|
||||||
private final Int2ObjectMap<T> idMap = new Int2ObjectOpenHashMap<>();
|
private final Int2ObjectMap<T> idMap = new Int2ObjectOpenHashMap<>();
|
||||||
|
private final Collection<T> objects = Collections.unmodifiableCollection(namespaceMap.values());
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public Container(Resource resource, Loader<T> loader) {
|
public Container(Resource resource, Loader<T> loader) {
|
||||||
@ -90,7 +91,7 @@ public final class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Collection<T> values() {
|
public Collection<T> values() {
|
||||||
return Collections.unmodifiableCollection(namespaceMap.values());
|
return objects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register(@NotNull T value) {
|
public void register(@NotNull T value) {
|
||||||
|
Loading…
Reference in New Issue
Block a user