mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-30 21:17:53 +01:00
Warn about EventNode#map performance
This commit is contained in:
parent
d9c000f80a
commit
6f88abf987
@ -352,9 +352,24 @@ public interface EventNode<T extends Event> {
|
||||
@Contract(value = "_ -> this")
|
||||
@NotNull EventNode<T> removeListener(@NotNull EventListener<? extends T> listener);
|
||||
|
||||
/**
|
||||
* Maps a specific object to a node.
|
||||
* <p>
|
||||
* Be aware that such structure have huge performance penalty as they will
|
||||
* always require a map lookup. Use only at last resort.
|
||||
*
|
||||
* @param node the node to map
|
||||
* @param value the mapped value
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
void map(@NotNull EventNode<? extends T> node, @NotNull Object value);
|
||||
|
||||
/**
|
||||
* Undo {@link #map(EventNode, Object)}
|
||||
*
|
||||
* @param value the value to unmap
|
||||
* @return true if the value has been unmapped, false if nothing happened
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
boolean unmap(@NotNull Object value);
|
||||
|
||||
|
@ -326,8 +326,7 @@ class EventNodeImpl<T extends Event> implements EventNode<T> {
|
||||
// Retrieve all filters used to retrieve potential handlers
|
||||
for (var mappedEntry : mappedNodeCache.entrySet()) {
|
||||
final EventNodeImpl<E> mappedNode = mappedEntry.getValue();
|
||||
final Class<E> mappedNodeType = mappedNode.eventType;
|
||||
if (!mappedNodeType.isAssignableFrom(eventType)) continue;
|
||||
if (!mappedNode.eventType.isAssignableFrom(eventType)) continue;
|
||||
if (mappedNode.listenerMap.isEmpty())
|
||||
continue; // The mapped node does not have any listener (perhaps throw a warning?)
|
||||
filters.add(mappedNode.filter);
|
||||
|
Loading…
Reference in New Issue
Block a user