return q->items[q->cur].location;
}
+/** \brief Returns the type of the last event in the queue. */
+static really_inline u32 q_last_type(const struct mq *q) {
+ assert(q->cur < q->end);
+ assert(q->end > 0);
+ assert(q->end <= MAX_MQE_LEN);
+ return q->items[q->end - 1].type;
+}
+
/** \brief Returns the location (relative to the beginning of the current data
* buffer) of the last event in the queue. */
static really_inline s64a q_last_loc(const struct mq *q) {
DEBUG_PRINTF("ensure MQE_END %lld for queue %u\n", final_loc, qi);
if (final_loc >= q_last_loc(q)) {
/* TODO: ensure situation does not arise */
- assert(q->items[q->end - 1].type != MQE_END);
+ assert(q_last_type(q) != MQE_END);
pushQueueNoMerge(q, MQE_END, final_loc);
}
}
q_skip_forward_to(q, miracle_loc);
- if (q->items[q->end - 1].type == MQE_START) {
+ if (q_last_type(q) == MQE_START) {
DEBUG_PRINTF("miracle caused infix to die\n");
return 0;
}
}
}
- if (q_cur_loc(q) < loc || q->items[q->end - 1].type != MQE_START) {
+ if (q_cur_loc(q) < loc || q_last_type(q) != MQE_START) {
if (left->infix) {
if (infixTooOld(q, loc)) {
DEBUG_PRINTF("infix %u died of old age\n", ri);
DEBUG_PRINTF("skip q forward, %lld to %lld\n", begin_loc, miracle_loc);
q_skip_forward_to(q, miracle_loc);
- if (q->items[q->end - 1].type == MQE_START) {
+ if (q_last_type(q) == MQE_START) {
DEBUG_PRINTF("miracle caused infix to die\n");
return MIRACLE_DEAD;
}