Changeset 129


Ignore:
Timestamp:
Aug 16, 2010, 11:40:14 PM (10 years ago)
Author:
sam
Message:

Minor optimisation in the garbage collection order.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ticker.cpp

    r126 r129  
    8080    data->bias += data->delta_time;
    8181
    82     /* Insert waiting objects in the appropriate lists */
    83     while (data->todo)
    84     {
    85         Asset *a = data->todo;
    86         data->todo = a->next;
    87 
    88         int i = a->GetGroup();
    89         a->next = data->list[i];
    90         data->list[i] = a;
    91         data->nassets++;
    92     }
    93 
    94     /* Garbage collect objects that can be destroyed */
     82    /* Garbage collect objects that can be destroyed. We can do this
     83     * before inserting awaiting objects, because there is no way these
     84     * are already marked for destruction. */
    9585    for (int i = 0; i < Asset::GROUP_COUNT; i++)
    9686        for (Asset *a = data->list[i], *prev = NULL; a; prev = a, a = a->next)
     
    10595                delete a;
    10696            }
     97
     98    /* Insert waiting objects into the appropriate lists */
     99    while (data->todo)
     100    {
     101        Asset *a = data->todo;
     102        data->todo = a->next;
     103
     104        int i = a->GetGroup();
     105        a->next = data->list[i];
     106        data->list[i] = a;
     107        data->nassets++;
     108    }
    107109
    108110    /* Tick objects for the game loop */
Note: See TracChangeset for help on using the changeset viewer.