mirror of
https://github.com/Minestom/Minestom.git
synced 2024-11-05 10:20:42 +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<>();
|
||||
// id -> registry data
|
||||
private final Int2ObjectMap<T> idMap = new Int2ObjectOpenHashMap<>();
|
||||
private final Collection<T> objects = Collections.unmodifiableCollection(namespaceMap.values());
|
||||
|
||||
@ApiStatus.Internal
|
||||
public Container(Resource resource, Loader<T> loader) {
|
||||
@ -90,7 +91,7 @@ public final class Registry {
|
||||
}
|
||||
|
||||
public Collection<T> values() {
|
||||
return Collections.unmodifiableCollection(namespaceMap.values());
|
||||
return objects;
|
||||
}
|
||||
|
||||
public void register(@NotNull T value) {
|
||||
|
Loading…
Reference in New Issue
Block a user