Skip to content

Commit 8a5c088

Browse files
committed
Avoid an allocating lambda in ListenerListInst#buildCache
1 parent ef646f1 commit 8a5c088

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/main/java/net/minecraftforge/eventbus/ListenerList.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,17 +192,16 @@ private void addChild(ListenerListInst child) {
192192
* Rebuild the local Array of listeners, returns early if there is no work to do.
193193
*/
194194
private void buildCache() {
195-
if(parent != null && parent.shouldRebuild())
195+
if (parent != null && parent.shouldRebuild())
196196
parent.buildCache();
197197

198198
ArrayList<IEventListener> ret = new ArrayList<>();
199-
Arrays.stream(EVENT_PRIORITY_VALUES).forEach(value -> {
199+
for (EventPriority value : EVENT_PRIORITY_VALUES) {
200200
List<IEventListener> listeners = getListeners(value);
201-
if (!listeners.isEmpty()) {
202-
ret.add(value); //Add the priority to notify the event of it's current phase.
203-
ret.addAll(listeners);
204-
}
205-
});
201+
if (listeners.isEmpty()) continue;
202+
ret.add(value); // Add the priority to notify the event of its current phase.
203+
ret.addAll(listeners);
204+
}
206205
this.listeners.set(ret.toArray(new IEventListener[0]));
207206
rebuild = false;
208207
}

0 commit comments

Comments
 (0)