Skip to content

Commit

Permalink
Some simplification
Browse files Browse the repository at this point in the history
  • Loading branch information
JanWielemaker committed Dec 30, 2024
1 parent 5528aa6 commit cd0e54e
Showing 1 changed file with 16 additions and 29 deletions.
45 changes: 16 additions & 29 deletions src/pl-termwalk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit cd0e54e

Please sign in to comment.