Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit 52e0aa2

Browse files
committed
Reorganized event back-references to be easier to read
All queue manipulations are currently synchronized, so order is irrelevant. Moving the back-references after the reference assignment makes the dependents of the back-references more notable.
1 parent be5ffc1 commit 52e0aa2

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

equeue.c

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -167,42 +167,40 @@ static void equeue_enqueue(equeue_t *q, struct equeue_event *e, unsigned ms) {
167167
}
168168

169169
if (*p && (*p)->target == e->target) {
170-
if (*p) {
171-
(*p)->ref = &e->sibling;
170+
e->next = (*p)->next;
171+
if (e->next) {
172+
e->next->ref = &e->next;
172173
}
173-
e->sibling = *p;
174174

175-
if ((*p)->next) {
176-
(*p)->next->ref = &e->next;
177-
}
178-
e->next = (*p)->next;
175+
e->sibling = *p;
176+
e->sibling->ref = &e->sibling;
179177
} else {
180-
if (*p) {
181-
(*p)->ref = &e->next;
182-
}
183178
e->next = *p;
179+
if (e->next) {
180+
e->next->ref = &e->next;
181+
}
184182

185183
e->sibling = 0;
186184
}
187185

188-
e->ref = p;
189186
*p = e;
187+
e->ref = p;
190188
}
191189

192190
static void equeue_unqueue(equeue_t *q, struct equeue_event *e) {
193191
if (e->sibling) {
194-
if (e->next) {
195-
e->next->ref = &e->sibling->next;
196-
}
197192
e->sibling->next = e->next;
193+
if (e->sibling->next) {
194+
e->sibling->next->ref = &e->sibling->next;
195+
}
198196

199-
e->sibling->ref = e->ref;
200197
*e->ref = e->sibling;
198+
e->sibling->ref = e->ref;
201199
} else {
200+
*e->ref = e->next;
202201
if (e->next) {
203202
e->next->ref = e->ref;
204203
}
205-
*e->ref = e->next;
206204
}
207205
}
208206

0 commit comments

Comments
 (0)