Skip to content

Commit d3848de

Browse files
committed
Assign the priorities field in the field declaration
1 parent 2e6c710 commit d3848de

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,21 @@ private static class ListenerListInst {
104104

105105
private boolean rebuild = true;
106106
private AtomicReference<IEventListener[]> listeners = new AtomicReference<>();
107-
private final @Nullable ArrayList<IEventListener>[] priorities;
107+
108+
/** A lazy-loaded array of lists containing listeners for each priority level. */
109+
@SuppressWarnings("unchecked")
110+
private final @Nullable ArrayList<IEventListener>[] priorities =
111+
(ArrayList<IEventListener>[]) new ArrayList[EVENT_PRIORITY_VALUES.length];
112+
108113
private ListenerListInst parent;
109114
private List<ListenerListInst> children;
110115
private final Semaphore writeLock = new Semaphore(1, true);
111116

112-
@SuppressWarnings("unchecked")
113-
private ListenerListInst() {
114-
// Make a lazy-loaded array of lists containing listeners for each priority level.
115-
priorities = (ArrayList<IEventListener>[]) new ArrayList[EVENT_PRIORITY_VALUES.length];
117+
private ListenerListInst() {}
118+
119+
private ListenerListInst(ListenerListInst parent) {
120+
this.parent = parent;
121+
this.parent.addChild(this);
116122
}
117123

118124
public void dispose() {
@@ -131,12 +137,6 @@ public void dispose() {
131137
children.clear();
132138
}
133139

134-
private ListenerListInst(ListenerListInst parent) {
135-
this();
136-
this.parent = parent;
137-
this.parent.addChild(this);
138-
}
139-
140140
/**
141141
* Returns a ArrayList containing all listeners for this event,
142142
* and all parent events for the specified priority.

0 commit comments

Comments
 (0)