Branch: Tag:

2012-02-09

2012-02-09 13:29:48 by Arne Goedeke <el@laramies.com>

make ba_free fast path smaller

497:   #endif    if (!p) {   #ifdef BA_HASH_THLD -  if (a->allocated <= BA_HASH_THLD) -  BA_ERROR("ba_low_free(.., %p) should never be called: %d, %d\n", -  ptr, a->allocated, BA_HASH_THLD); +  if (a->num_pages <= BA_HASH_THLD) { +  ba_page_t t; +  for (t = 0; t < a->num_pages; t++) { +  if (BA_CHECK_PTR(a, a->pages[t], ptr)) { +  a->last_free = p = a->pages[t]; +  a->last_free_num = n = t + 1; +  break; +  } +  } +  } else {   #endif    n = ba_htable_lookup(a, ptr);    if (n) {    a->last_free = p = BA_PAGE(a, n);    a->last_free_num = n; -  } else { +  } + #ifdef BA_HASH_THLD +  } + #endif   #ifdef BA_DEBUG    fprintf(stderr, "magnitude: %u\n", a->magnitude);    fprintf(stderr, "allocated: %u\n", a->allocated);
515: Inside #if defined(BA_DEBUG)
   );    ba_print_htable(a);   #endif +  if (!p)    BA_ERROR("Unknown pointer (not found in hash) %p\n", ptr);    } -  } +        if (p->blocks_used == a->blocks) {    if (a->first) {