Ignore:
Timestamp:
Feb 15, 2010, 4:44:02 PM (12 years ago)
Author:
charles
Message:

(trunk libT) instead of growing the ptrArray by a constant fixed amount when it runs out of room, follow exponential growth to minimize the number of realloc()s needed. This speeds up populating large arrays in bencode.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/ptrarray.c

    r10207 r10209  
    1818#include "utils.h"
    1919
    20 #define GROW 32
     20#define FLOOR 32
    2121
    2222const tr_ptrArray TR_PTR_ARRAY_INIT = { NULL, 0, 0 };
     
    7979    if( t->n_items >= t->n_alloc )
    8080    {
    81         t->n_alloc = t->n_items + GROW;
     81        t->n_alloc = MAX( FLOOR, t->n_alloc * 2 );
    8282        t->items = tr_renew( void*, t->items, t->n_alloc );
    8383    }
Note: See TracChangeset for help on using the changeset viewer.