diff --git a/src/pl-termwalk.c b/src/pl-termwalk.c index 88c7a65df2..8a50f1d9d1 100644 --- a/src/pl-termwalk.c +++ b/src/pl-termwalk.c @@ -80,19 +80,15 @@ static inline Word nextTermAgenda(DECL_LD term_agenda *a) { Word p; - if ( a->work.size > 0 ) - { ok: - a->work.size--; - p = a->work.location++; - deRef(p); - - return p; - } + if ( unlikely(a->work.size == 0) && + !popSegStack(&a->stack, &a->work, aNode) ) + return NULL; - if ( popSegStack(&a->stack, &a->work, aNode) ) - goto ok; + a->work.size--; + p = a->work.location++; + deRef(p); - return NULL; + return p; }