pre-allocate h_desugar's result to squelch recursive calls
This commit is contained in:
parent
8618f9cb62
commit
7b04ab8d9d
3 changed files with 10 additions and 3 deletions
|
|
@ -8,9 +8,11 @@ HCFChoice *h_desugar(HAllocator *mm__, HCFStack *stk__, const HParser *parser) {
|
|||
if (nstk__ == NULL) {
|
||||
nstk__ = h_cfstack_new(mm__);
|
||||
}
|
||||
if(nstk__->prealloc == NULL)
|
||||
nstk__->prealloc = h_new(HCFChoice, 1);
|
||||
// we're going to do something naughty and cast away the const to memoize
|
||||
((HParser *)parser)->desugared = nstk__->prealloc;
|
||||
parser->vtable->desugar(mm__, nstk__, parser->env);
|
||||
((HParser *)parser)->desugared = nstk__->last_completed;
|
||||
if (stk__ == NULL)
|
||||
h_cfstack_free(mm__, nstk__);
|
||||
} else if (stk__ != NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue