Changeset 630


Ignore:
Timestamp:
May 10, 2011, 8:31:42 PM (7 years ago)
Author:
Sam Hocevar
Message:

lisp: fix a tail recursion bug in the List object collector that caused
excessive stack usage.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/lisp/lisp_gc.cpp

    r561 r630  
    5555LList *LispGC::CollectList(LList *x)
    5656{
    57     LList *last = NULL, *first = NULL;
     57    LList *prev = NULL, *first = NULL;
    5858
    5959    for (; x && item_type(x) == L_CONS_CELL; )
     
    6161        LList *p = LList::Create();
    6262        LObject *old_car = x->car;
    63         LObject *old_cdr = x->cdr;
    6463        LObject *old_x = x;
    6564        x = (LList *)CDR(x);
     
    6867
    6968        p->car = CollectObject(old_car);
    70         p->cdr = CollectObject(old_cdr);
    71 
    72         if (last)
    73             last->cdr = p;
     69
     70        if (prev)
     71            prev->cdr = p;
    7472        else
    7573            first = p;
    76         last = p;
     74        prev = p;
    7775    }
    7876    if (x)
    79         last->cdr = CollectObject(x);
     77        prev->cdr = CollectObject(x);
     78
    8079    return first; // we already set the collection pointers
    8180}
Note: See TracChangeset for help on using the changeset viewer.