From cd0e54e3c6b573e4c4e8f9b63ff28b296480b8c6 Mon Sep 17 00:00:00 2001 From: Jan Wielemaker Date: Mon, 30 Dec 2024 13:48:12 +0100 Subject: [PATCH] Some simplification --- src/pl-termwalk.c | 45 ++++++++++++++++----------------------------- 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/src/pl-termwalk.c b/src/pl-termwalk.c index 8a50f1d9d1..25f6f84403 100644 --- a/src/pl-termwalk.c +++ b/src/pl-termwalk.c @@ -75,56 +75,43 @@ clearTermAgenda(term_agenda *a) } -#define nextTermAgenda(a) LDFUNC(nextTermAgenda, a) static inline Word -nextTermAgenda(DECL_LD term_agenda *a) -{ Word p; - - if ( unlikely(a->work.size == 0) && +nextTermAgendaNoDeRef(term_agenda *a) +{ if ( unlikely(a->work.size == 0) && !popSegStack(&a->stack, &a->work, aNode) ) return NULL; a->work.size--; - p = a->work.location++; - deRef(p); - - return p; + return a->work.location++; } +#define nextTermAgenda(a) LDFUNC(nextTermAgenda, a) static inline Word -nextTermAgendaNoDeRef(term_agenda *a) -{ Word p; - - if ( a->work.size > 0 ) - { ok: - a->work.size--; - p = a->work.location++; - - return p; - } +nextTermAgenda(DECL_LD term_agenda *a) +{ Word p = nextTermAgendaNoDeRef(a); - if ( popSegStack(&a->stack, &a->work, aNode) ) - goto ok; + if ( p ) + deRef(p); - return NULL; + return p; } - - /******************************* * PUSH VARIATIONS * *******************************/ static inline int pushWorkAgenda(term_agenda *a, size_t amount, Word start) -{ if ( a->work.size > 0 ) - { if ( !pushSegStack(&a->stack, a->work, aNode) ) - return false; +{ if ( amount ) + { if ( a->work.size > 0 ) + { if ( !pushSegStack(&a->stack, a->work, aNode) ) + return false; + } + a->work.location = start; + a->work.size = amount; } - a->work.location = start; - a->work.size = amount; return true; }